LibXML with Labview - no namespace prefix

喜夏-厌秋 提交于 2019-12-11 07:33:32

问题


I have been using Labview's native XML parser to read an XML document. As it turns out, it is too slow for large files. I therefore am trying to use LibXML as it seems to be quite popular. However, I am having trouble with namespaces. I have a third-party XML document that comes like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<foo xmlns="urn:foo_Schema_V3">
     <bar>
        <fooID description="XML Test 170731"></fooID>
        <barNumber>60</barNumber>      
    </bar>
</foo>

and would like to select the barNumber using Labview which uses XPath.

The content text should be 60, however it remains empty. I read up a little and assume this is due to namespace issues in LibXML. As a test, I changed the second line in XML to

<foo xmlns:cliff="urn:foo_Schema_V3">

suddenly, the XPath expression works even though cliff is never even mentioned in Labview.

Q: How can I select the node I want without having a namespace prefix?

Update: I have taken to using /*[local-name()='foo']/*[local-name()='bar']/*[local-name()=‌​'barNumber'], which is not elegant and does not explain WHY a node is not selectable without prefix.

来源:https://stackoverflow.com/questions/45420058/libxml-with-labview-no-namespace-prefix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!