XPath support in Xerces-C

Adam Tegen picture Adam Tegen · Jul 9, 2009 · Viewed 8.2k times · Source

I am supporting a legacy C++ application which uses Xerces-C for XML parsing. I've been spoiled by .Net and am used to using XPath to select nodes from a DOM tree.

Is there any way to get access some limited XPath functionality in Xerces-C? I'm looking for something like selectNodes("/for/bar/baz"). I could do this manually, but XPath is so nice by comparison.

Answer

Matt Hook picture Matt Hook · Jul 10, 2009

See the xerces faq.

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

Does Xerces-C++ support XPath? No.Xerces-C++ 2.8.0 and Xerces-C++ 3.0.1 only have partial XPath implementation for the purposes of handling Schema identity constraints. For full XPath support, you can refer Apache Xalan C++ or other Open Source Projects like Pathan.

It's fairly easy to do what you want using xalan however.