libxml2 xpath 解析含有 prefix namespace 的 xml

有一段xml 里面有 prefix  URL namespace的 , 这时用xpath解析 像平常那样写解析不出来节点

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <GetTokenResponse xmlns="urn:LBaseComponents">
   <Timestamp>2012-11-06T05:04:55.256Z</Timestamp>
   <Ack>Success</Ack>
   <AuthToken>xxxxx</AuthToken>
  </GetTokenResponse>
 </soapenv:Body>
</soapenv:Envelope>
 

google了一下 最后用

@"//*[local-name()='AuthToken'] "

 

 解决了

 

文章 link: http://www.velocityreviews.com/forums/t169475-xpath-and-namespaces-a-newbie-question.html

扫描二维码关注公众号,回复: 758537 查看本文章

 

还找到一个在线的xpath test 站点   http://www.xpathtester.com

 

 

猜你喜欢

转载自renxiangzyq.iteye.com/blog/1717415