0
我试图使用xpathGetStringxpathGetString总是返回空字符串
String abcd = lc_CustomXmlPart.xpathGetString("/Contract/Currency[1]/@Code", "");
System.out.println(abcd);
从CustomXmlPart读取属性,但它总是返回空字符串。
XML看起来是这样的:
<Contract xmlns="http://abc.123.cz" TypeCode="HO" IssueDate="2017-02-11">
<Currency Code="EUR" Name="Default" PrintCode="€"></Currency>
</Contract>
有人能告诉我什么我做错了?
非常感谢你! –
@PiotrJanuszWijas不客气!我记得头刮,因为偷偷摸摸'xmlns'的一些长会议;) – Aaron
您可能还可以在XML声明命名空间前缀(例如:的xmlns:ABC =“http://abc.123.cz” ),然后根据此答案使用该前缀。 – JasonPlutext