xpath issue with libxml

xpath issue with libxml

BY 02 Jun 2015 Native Application Development
Hi, I am in write a xml parse demo app, I want to use xpath to query a specific element in a xml file. It’s ok for a normal xml format file. But if the xml element has a namespace prefix, I can’t get the result via xpath. example: xml snippet, 2015-06-02T09:19:29.535Z … as above, the root element “Search” with a namespace prefix “ns2”, my xpath is “/ns:Search/Response/View/ViewId”, it’s not work, I also try xpath as “/Search/Response/View/ViewId”, not work. it’s ok with a relative xpath “Response/View/ViewId”. I guess it’s a namespace related issue, I want to fix it, currently, I don’t find a full guide about xpath syntax. anyone can help me? thanks a lot.
Written by