zoukankan      html  css  js  c++  java
  • 把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;
    "
    双引号
  • 相关阅读:
    关于AJAX与form表单提交数据的格式
    MongoDB
    Redis
    在django中使用django_debug_toolbar进行日志记录
    python第三方库,你要的这里都有
    Django之用户认证auth模块
    Django中常用命令
    form表单钩子,局部钩子和全局钩子
    当我开始爱自己
    FOR YOU
  • 原文地址:https://www.cnblogs.com/mengzhixingping/p/3545680.html
Copyright © 2011-2022 走看看