gpt4 book ai didi

java - SAXException=XML 文档结构必须在同一实体内开始和结束

转载 作者:行者123 更新时间:2023-12-01 21:49:26 26 4
gpt4 key购买 nike

有人可以告诉我为什么会出现这个解析错误吗? XML 对我来说看起来不错。它因 SAXException=XML 文档结构必须在同一实体内开始和结束而失败。在这一行:

Document doc = builder.parse(inputSource);  //fails here

这是代码:

        String soapIn = "<?xml version='1.0' encoding='UTF-8' ?>\n" +
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:vid=\"http://videocontrollerchannelmap.queryservice.vcwh.oss.my.company.com/\">\n" +
" <soapenv:Header/>\n" +
" <soapenv:Body>\n" +
" <vid:getInneoquestChannelMap>\n" +
" <appkey>ONE_CONTROLLER</appkey>\n" +
" <forceUpdate>true</forceUpdate>\n" +
" </vid:getInneoquestChannelMap>\n" +
" </soapenv:Body>\n" +
"</soapenv:Envelope";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
SOAPMessage newMsg = null;
try {
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource inputSource = new InputSource(new StringReader(soapIn));
Document doc = builder.parse(inputSource); //fails here
DOMSource domSource = new DOMSource(doc);

最佳答案

您缺少>"</soapenv:Envelope" .

关于java - SAXException=XML 文档结构必须在同一实体内开始和结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35419508/

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