• 把DataTable中的数据拼接成XML时遇到的问题


    错误信息:System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Name cannot begin with the '1' character, hexadecimal value 0x31. Line 1, position 918.
       at System.Xml.XmlTextReaderImpl.Throw(Exception e)
       at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
       at System.Xml.XmlTextReaderImpl.ParseQName(Boolean isQName, Int32 startOffset, Int32& colonPos)
       at System.Xml.XmlTextReaderImpl.ParseElement()
       at System.Xml.XmlTextReaderImpl.ParseElementContent()
       at System.Xml.XmlTextReaderImpl.Read()
       at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
       at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
       at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
       at System.Xml.XmlDocument.Load(XmlReader reader)
       at System.Xml.XmlDocument.LoadXml(String xml)
       at BasInfomation.BasWebService.IsExsist(String xml, Int32 tag)
       at BasInfomation.BasWebService.GetBasInfo(Int32 tag, String basInfo)
       --- End of inner exception stack trace ---
       在 System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
       在 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       在 DataReport.WebInf.BasWebService.GetBasInfo(Int32 tag, String basInfo)
       在 DataReport.frmAutoUpdate.DataToXml(DataTable dtXml)
    发生在:

    错误解决:

     1、改头文件:sbXML.Append("<?xml version='1.0' encoding='utf-8'?>");为sbXML.Append("<?xml version='1.0' encoding='UTF-8'?>");

                      改过之后问题并没有解决,还是报该错误,纠结啊纠结啊。。。。

    2、经过跟踪代码发现,并不是1中情况那样,而是取的数据中多了特殊符号(<  >等)如

        <MZZD>身体体表<10%烧伤</MZZD> <JBBM>T31.000</JBBM> <ZYZD>身体体表<10%烧伤</ZYZD>

        <和>号未经转义,就报上面的错误了,需要经过转义,下面是五个在XML文档中预定义好的实体:

    &lt;
    <
    小于号
    &gt;
    >
    大于号
    &amp;
    &
    &apos;
    '
    单引号
    &quot;
    "
    双引号
  • 相关阅读:
    4 stackstorm定时器基础 Sky
    3 stackstorm rule Sky
    2 stackstrom action Sky
    1 StackStorm介绍 Sky
    stackstorm安装 Sky
    stackstorm webui安装 Sky
    3.8 Go之并发和并行
    3.2 Go之语言竞争状态
    3.2 Go之语言并发通信
    图床_typora设置.md
  • 原文地址:https://www.cnblogs.com/mengzhixingping/p/3545680.html
Copyright © 2020-2023  润新知