开发者

Searching nodes - Libxml

开发者 https://www.devze.com 2023-01-18 10:27 出处:网络
开发者_运维百科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 pars

开发者_运维百科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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消