Tag: xfdl

XPath,XML命名空间和Java

我花了一天时间尝试从以下文档中提取一个XML节点,并且无法掌握XML命名空间的细微差别以使其工作。 XML文件总数很大,所以这是我关注的部分: HAND RECEIPT/ANNEX NUMBER 该文件继续存在并且形成良好。 我试图从“documentnbr”标签中提取“数字”属性(从底部三个)。 我用来执行此操作的代码如下所示: /*** * Locates the Document Number information in the file and returns the form number. * @return File’s self-declared number. * @throws InvalidFormException Thrown when XPath cannot find the “documentnbr” element in the file. */ public String getFormNumber() throws InvalidFormException { try{ XPath xPath = XPathFactory.newInstance().newXPath(); xPath.setNamespaceContext(new […]