我有这种 XML:
<?xml version="1.0" encoding="UTF-8"?>
<documentAnswer xmlns="http://schemas.pkh.hr/doc/2013/documents/rda_30" domainName="rda" domainVersion="3.0">
<answerTimestamp>2013-08-21T13:35:25.894</answerTimestamp>
<correct>
<docId>RDA2_29F81D27-1409BE49E2E-7FF8</docId>
<attachments>
<attachment>
<format>application/pdf</foraat>
<generatedType>StampanNaBlanko</generatedType>
<encodedPdf>JVBERiYKJSVFT0YK</encodedPdf>
</attachment>
</attachments>
</correct>
这些附件标签可以是一个或多个。我正在尝试使用 Java 中的附件标签获取 NodeIterator
XPathAPI.selectNodeIterator(node, "/documentAnswer/correct/attachments/attachment")
然后迭代,但我没有成功。我猜测问题出在 xpath 中,并且与命名空间有关,但不知道如何解决。我尝试使用这种 xpath 但没有成功:
XPathAPI.selectNodeIterator(节点,“/rda:documentAnswer/correct/attachments/attachment”,“rda”,“ http://schemas.pkh.hr/doc/2013/documents/rda_30 ”)