You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修复依赖以解决XML文件解析失败问题?

问题:XML解析第166行报错,调整依赖无效

我已在Stack Overflow上搜索解决方法,但均无效。代码持续在第166行报错,我认为这与我的pom文件有关,但无法找到修复方法。

报错代码

160         DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
161         System.out.println("DB is"+db);
// 输出:DB isorg.apache.xerces.jaxp.DocumentBuilderImpl@763334fe

162         InputSource is = new InputSource();
163         System.out.println("is= "+is);
// 输出:is= org.xml.sax.InputSource@7fc7ed31

164         is.setCharacterStream(new StringReader(strXMLResponse));
165         System.out.println("strXMLResponse" + strXMLResponse);
// 输出:strXMLResponse

166         Document doc = db.parse("is"+is);
167         System.out.println("doc"+doc);

168         nodes = doc.getElementsByTagName("Value");
169         System.out.println("node"+nodes);

当前pom依赖(JDK 17.0.4.1)

<dependencies>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.5.0-b01</version>
    </dependency>
  
    <dependency>                
         <groupId>junit</groupId>                               
         <artifactId>junit</artifactId>                             
         <version>3.8.1</version>                               
         <scope>test</scope>                                
    </dependency>
    <dependency>
        <groupId>jakarta.xml.ws</groupId>
        <artifactId>jakarta.xml.ws-api</artifactId>
        <version>4.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>4.0.0</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

<properties>
    <target.dir>target2</target.dir>
</properties>

我已修改pom依赖和导入语句,也在Stack Overflow查找过答案,但均无效果。

内容的提问来源于stack exchange,提问作者rgw

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 05:39:52