views:

35

answers:

1

Hello all...

I am trying to parse an XML document in C++. I do not have any form of metadata associated with the document. Since i am a novice with XML's i wanted to understand the best way to parse this xml. I am using libxml2 to achive this.

What i am doing currently is 1) walking the complete tree node by node , using pointers of the root node of document. 2) Comparing & looking for the node i need , extracting the value. 3) repeat 1-2;

Is this the best possible way to do it , constrained by the library ? I ran through the API , but could not find something that would fit the bill.

Cheers!

+1  A: 

The "best way" probably depends on your application. XPath is another alternative for finding a specific node or list of nodes. libxml2 example code here and here.

General XPath examples here.

dgnorton