gpt4 book ai didi

java - 构建DOM文档对象时文件过早结束错误

转载 作者:行者123 更新时间:2023-12-03 09:02:44 25 4
gpt4 key购买 nike

当我创建Document对象时,我遇到了文件结尾过早的错误。这段代码几天前就在工作,现在我不确定是什么原因导致它引发错误。

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource is = new InputSource(new StringReader(response));
Document doc = builder.parse(is);

[Fatal Error] :1:1: Premature end of file.



这是我收到的响应xml。看起来很好。
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetBatchFilesResponse xmlns="http://....">
<GetBatchFilesResult>
<BatchFile>
<Uri>someURI</Uri>
<ID>2025961</ID>
<FQName>someFileName</FQName>
</BatchFile>
</GetBatchFilesResult>
</GetBatchFilesResponse>
</soap:Body>
</soap:Envelope>

最佳答案

该消息表明您有一个格式不正确的 XML响应的。通常,当XML中有一个没有匹配的结束标签的开始标签时,会 pop 此消息。我想您也会在响应中得到此信息。

关于java - 构建DOM文档对象时文件过早结束错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15504646/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com