【发布时间】:2014-02-21 07:42:37
【问题描述】:
我有以下 xml 格式。我需要获取 'typename1' 并写了 //*[local-name() = 'type-name' 和 text() ='typeName1']。如果 'type-name' 是 'typeName1' 使用 XPath 查询表达式,有人可以帮助我如何获取 'objectid1'。
<?xml-stylesheet type="text/xsl" href="/API/xsl/abcde.xml" ?>
<name xmlns="http://www.ccc.org/2011/SSS" xmlns:hostmgmt='http://www.xyzw.com/abcd'>
<title type="text">test</title>
<content>
<id>48035</id>
<host-contacts>
<host-contact>
<host-contact-type>Employee</host-contact-type>
<host-contact-role>Role</host-contact-role>
<host-contact-name>Employee Name</host-contact-name>
</host-contact>
</host-contacts>
<syslog-messages>N</syslog-messages>
<services>
<service>
<objectid>objectid1</objectid>
<type-name>typeName1</type-name>
</service>
<service>
<objectid>objectid2</objectid>
<type-name>typeName2</type-name>
</service>
</services>
<building>ABC</building>
<asset>XYZ</asset>
</content>
</name>
【问题讨论】:
标签: xpath