注意:我正在处理我不知道他们的结构的xml文件因此我不能使用XPath
这是我的xml文件的一个例子:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
<HWData>
<Header time="2013-05-29T13:39:34" uploaded="true" version="1.0" />
<NE vendorName="Nokia Siemens Networks" NEId="WBTS-431">
<EQHO vendorName="Nokia Siemens Networks" equipmentHolderId="173" >
<UNIT vendorName="N" unitId="16" />
<UNIT vendorName="NOKIA SIEMENS NETWORKS" unitId="225" />
</EQHO>
<EQHO vendorName="NSN" equipmentHolderId="40192" >
<UNIT vendorName="AR" unitId="40267" />
</EQHO>
</NE>
<NE vendorName="Nokia Siemens Networks" NEId="WBTS-261">
<EQHO vendorName="Nokia Siemens Networks" equipmentHolderId="132" >
<EQHO vendorName="Nokia Siemens Networks" equipmentHolderId="132-1">
<UNIT vendorName="NN" unitId="1621" />
</EQHO>
</EQHO>
</NE>
</HWData>
我想知道我是否可以使用例如节点名称“NE”和属性值NEID =“WBTS-261”来获得结果!
结果预期:
<NE vendorName="Nokia Siemens Networks" NEId="WBTS-261">
<EQHO vendorName="Nokia Siemens Networks" equipmentHolderId="132" >
<EQHO vendorName="Nokia Siemens Networks" equipmentHolderId="132-1">
<UNIT vendorName="NN" unitId="1621" />
</EQHO>
</EQHO>
</NE>
有人可以让我以正确的方式做任何一个例子,想法或建议将不胜感激.. 谢谢