我见过的名称空间不可知语法令我困惑.
说我有:
<root>
<parent attribute="A">A<child>A</child></parent>
<parent attribute="B">B<child>B</child></parent>
</root>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我看到如何:
/root/parent/child/text()
Run Code Online (Sandbox Code Playgroud)
翻译为:
/*[local-name()='root']/*[local-name()='parent']/*[local-name()='child']/text()
Run Code Online (Sandbox Code Playgroud)
但我正在努力做这样的事情:
/root/parent[@attribute="A"]/child/text()
Run Code Online (Sandbox Code Playgroud)
要么:
/root/parent[text()="B"]/child/text()
Run Code Online (Sandbox Code Playgroud)
要么:
/root/parent[1]/child/text()
Run Code Online (Sandbox Code Playgroud)
这些翻译怎么样?
谢谢,
编辑:再一次:-)
<root>
<parent>
<childName>serverName</childName>
<childValue>MyServer</childValue>
</parent>
<parent>
<childName>ServerLocation</childName>
<childValue>Somewhere</childValue>
</parent>
</root>
Run Code Online (Sandbox Code Playgroud)
这是如何翻译的?
/root/parent[childName="serverName"]/childValue/text()
Run Code Online (Sandbox Code Playgroud)