You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by ol...@invensys.com on 2003/07/21 03:34:59 UTC

Querying an XML File

Hi folks,

not sure if I'm barking up the wrong tree here, but is there an API to
extract nodes from a file (or DOM) using XPath strings? This would be a
really powerful feature for manipulating trees.

==============================
Oliver White
Software Engineer
Product Development
Westinghouse Signals Australia
==============================


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


SV:Re: SV:Querying an XML File

Posted by Gröndal Daniel <da...@rfv.sfa.se>.
Hi!

I forgot, but that's true.

//daniel


Gareth Reakes  (2003-07-21  11:18):
>Hi,
>
>On 21 Jul 2003, Gröndal Daniel wrote:
>
>
>> Hi!
>>
>> That's a thing for Xalan. I do it that way. First I use Xerces (DOM) to do
some
>> stuff and then I wrap the DOM-tree and pass it to Xalan.
>
>Or Pathan (software.decisionsoft.com) which is an XPath module for
>xerces-c.
>
>Gareth
>
>--
>Gareth Reakes, Head of Product Development  +44-1865-203192
>DecisionSoft Limited                        http://www.decisionsoft.com
>XML Development and Services
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: SV:Querying an XML File

Posted by Gareth Reakes <ga...@decisionsoft.com>.
It is,

http://xml.apache.org/xerces-c/faq-other.html#faq-9



Gareth


On Mon, 21 Jul 2003, David J Craigon wrote:

> Surely this is an FAQ by now! Any chance of adding it to the web site?
> 
> David
> 
> 
> Gareth Reakes wrote:
> > Hi,
> > 
> > On 21 Jul 2003, Gröndal Daniel wrote:
> > 
> > 
> > 
> >>Hi!
> >>
> >>That's a thing for Xalan. I do it that way. First I use Xerces (DOM) to do some
> >>stuff and then I wrap the DOM-tree and pass it to Xalan.
> > 
> > 
> > Or Pathan (software.decisionsoft.com) which is an XPath module for 
> > xerces-c.
> > 
> > Gareth
> > 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 
> 

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: SV:Querying an XML File

Posted by David J Craigon <da...@arabidopsis.info>.
Surely this is an FAQ by now! Any chance of adding it to the web site?

David


Gareth Reakes wrote:
> Hi,
> 
> On 21 Jul 2003, Gröndal Daniel wrote:
> 
> 
> 
>>Hi!
>>
>>That's a thing for Xalan. I do it that way. First I use Xerces (DOM) to do some
>>stuff and then I wrap the DOM-tree and pass it to Xalan.
> 
> 
> Or Pathan (software.decisionsoft.com) which is an XPath module for 
> xerces-c.
> 
> Gareth
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: SV:Querying an XML File

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,

On 21 Jul 2003, Gröndal Daniel wrote:


> Hi!
> 
> That's a thing for Xalan. I do it that way. First I use Xerces (DOM) to do some
> stuff and then I wrap the DOM-tree and pass it to Xalan.

Or Pathan (software.decisionsoft.com) which is an XPath module for 
xerces-c.

Gareth

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


SV:Querying an XML File

Posted by Gröndal Daniel <da...@rfv.sfa.se>.
Hi!

That's a thing for Xalan. I do it that way. First I use Xerces (DOM) to do some
stuff and then I wrap the DOM-tree and pass it to Xalan.

More or less like this:

  try
   {
      XMLPlatformUtils::Initialize();
   }
   catch (const XMLException& toCatch)
   {
      char* message = XMLString::transcode(toCatch.getMessage());
         // throw exception with message
   }
   impl =
DOMImplementationRegistry::getDOMImplementation(XMLString::transcode("LS"));
   parser = ((DOMImplementationLS*)
impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
   doc = parser->parseURI("inputfile.xml");

  // do stuff with doc


  // use Xalan to evaluate xPath's
   XPathEvaluator::initialize();
   XPathEvaluator    eval;

   XercesDOMSupport domsupport;
   XercesParserLiaison parserLiaison;        // for communication

   // xml-file is already parsed. don't want to do that again
   const XercesDOMWrapperParsedSource parsedSource(
                                   doc,
                                   parserLiaison,
                                   domsupport);


  // count nodes as example
   XalanDocument* xalanDoc = parsedSource.getDocument();

  // get root node
   XalanElement* rootElement= xalanDoc->getDocumentElement();

  // select all nodes that matches xPath
  // read xPath from user or whatever
   NodeRefList nodelist = eval.selectNodeList (domsupport, (XalanNode*)
rootElement, XalanDOMString(xpath.c_str()).c_str());
   int elements = nodelist.getLength();

  // and so on


Don't know if this is the fastest way do to stuff. It is just one way to do it..
.
You can also manipulate trees (I think?) with Xalan and write them back using
Xerces

//daniel


oliver.white@invensys.com  (2003-07-21  03:34):
>Hi folks,
>
>not sure if I'm barking up the wrong tree here, but is there an API to
>extract nodes from a file (or DOM) using XPath strings? This would be a
>really powerful feature for manipulating trees.
>
>==============================
>Oliver White
>Software Engineer
>Product Development
>Westinghouse Signals Australia
>==============================
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org