简体   繁体   English

用于解析XML属性的XPath

[英]XPath for parsing XML attributes

Can someone please tell me the "correct / most-efficient way" of getting the "Status" XML attributes (ID, CssClass, Description, and IsActive for the XML below: 有人可以告诉我获取“状态” XML属性(以下XML的ID,CssClass,Description和IsActive)的“正确/最有效的方法”:

Implementation will be Java - (but I am more interested in the XPath): 实现将是Java-(但我对XPath更加感兴趣):

<ArrayOfLineStatus>
<LineStatus ID="0" StatusDetails="">
    <BranchDisruptions/><Line ID="1" Name="Bakerloo"/>
    <Status ID="GS" CssClass="GoodService" Description="Good Service" IsActive="true">          
    <StatusType ID="1" Description="Line"/></Status></LineStatus>
[snip]
 </ArrayOfLineStatus>

Thank, 谢谢,

Miles. 英里。

@* selects all attributes of the context node. @*选择上下文节点的所有属性。 Use: 采用:

/*/*/Status/@*

Or, more specifically: 或者,更具体地说:

/ArrayOfLineStatus/LineStatus/Status/@*

Or, for Status elements appearing anywhere in the document: 或者,对于出现在文档中任何位置的Status元素:

//Status/@*

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM