使用libxml2的xpath进行节点查询时。在测试中十分正常。后来在应用中发现总是无法找到结果。返回结果数为空。
对比测试文件与系统生成xml文件发现关于xmlns属性变化引起异常。
当使用无prefix命名空间时,会引起此异常xmlns="http://www..com.cn/xxx.xsd"
百度N个网页后找到替代方案"//*[local-name()='UserTag'][@name=\'%s\']"
即在//*[local-name()='UserTag']中UserTag为节点名称@name=\'%s\'为属性name值