开发者

libxml2: xpath from xmlNode

开发者 https://www.devze.com 2023-04-03 23:12 出处:网络
I\'ve looked through the docs and it seems that you can only execute an xpath search from a xmlDocPtr by creating an xpath context. Is there anyway in libxml2 to xpath search fr开发者_JAVA百科om a xml

I've looked through the docs and it seems that you can only execute an xpath search from a xmlDocPtr by creating an xpath context. Is there anyway in libxml2 to xpath search fr开发者_JAVA百科om a xmlNodePtr?


Call xmlXPathNewContext(), specifying the real top-level xmlDocPtr for the document, then set the xmlXPathContext::node field to the desired xmlNodePtr pointer that is a child of the xmlDocPtr document.


It turns out you can cast xmlNodePtr to xmlDocPtr and visa-versa.

0

精彩评论

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

关注公众号