zoukankan      html  css  js  c++  java
  • XML 中的特殊字符

    XML中的特殊字符
    (个人用于记录,只是为解决一时的问题)

    1. Message         "An error occurredwhile parsing EntityName. Line 1, position 527."         string
    //z 2011-12-29 9:54 AM is2120@csdn
    事情的起源:
    在传入xml文件给XmlDocument的时候总是出现Exception(异常)
    //z 2011-12-29 9:54 AM is2120@csdn
    -                              $exception         {"An error occurred while parsingEntityName. Line 1, position 527."}      System.Exception{System.Xml.XmlException}

    -                              [System.Xml.XmlException]        {"An error occurred while parsingEntityName. Line 1, position 527."}                System.Xml.XmlException

    -                              base      {"An error occurred while parsingEntityName. Line 1, position 527."}      System.SystemException{System.Xml.XmlException}

    -                              base      {"An error occurred while parsingEntityName. Line 1, position 527."}      System.Exception{System.Xml.XmlException}

                                    _className        Cannot fetch the value of field'_className' because information about the containing class is unavailable.    string

                                    _data   Cannot fetch the value of field '_data'because information about the containing class is unavailable.                System.Collections.IDictionary

                                    _dynamicMethods          Cannot fetch the value of field'_dynamicMethods' because information about the containing class isunavailable.   object

                                    _exceptionMethod        Cannot fetch the value of field'_exceptionMethod' because information about the containing class isunavailable.   System.Reflection.MethodBase

                                    _exceptionMethodString             Cannot fetch the value of field'_exceptionMethodString' because information about the containing class isunavailable.     string

                                    _helpURL            Cannot fetch the value of field'_helpURL' because information about the containing class is unavailable.        string

                                    _HResult              Cannot fetch the value of field'_HResult' because information about the containing class is unavailable.        int

                                    _innerException               Cannot fetch the value of field'_innerException' because information about the containing class isunavailable.   System.Exception

                                    _message           Cannot fetch the value of field'_message' because information about the containing class is unavailable.    string

                                    _remoteStackIndex        Cannot fetch the value of field'_remoteStackIndex' because information about the containing class isunavailable.   int

                                    _remoteStackTraceString             Cannot fetch the value of field'_remoteStackTraceString' because information about the containing class isunavailable.     string

                                    _source                Cannot fetch the value of field'_source' because information about the containing class is unavailable.        string

                                    _stackTrace        Cannot fetch the value of field'_stackTrace' because information about the containing class is unavailable.    object

                                    _stackTraceString            Cannot fetch the value of field'_stackTraceString' because information about the containing class isunavailable.   string

                                    _xcode Cannot fetch the value of field '_xcode'because information about the containing class is unavailable.        int

                                    _xptrs   Cannot fetch the value of field '_xptrs'because information about the containing class is unavailable.        System.IntPtr

    +                             Data       {System.Collections.ListDictionaryInternal}          System.Collections.IDictionary{System.Collections.ListDictionaryInternal}
    //z 2011-12-29 9:54 AM is2120@csdn
    2. 解决方案
    2.1 xml中的特殊字符有5种:

    <

    小于号

    >

    大于号

    &

    &

    '

    '

    单引号

    "

    "

    双引号

    在xml文件中将相应的特殊(转义)字符替换掉即可
    //z 2011-12-29 9:54 AM is2120@csdn
    2.2 但是可以不用自己造车轮的
    微软提供了
    SecurityElement.Escape
    tagText = SecurityElement.Escape(tagText);


    2.3 XmlTextWriter Class 在内部对此也做了相应的处理

    //z 2011-12-29 9:54 AM is2120@csdn
    2.4 含有特殊字符的也可以放在CDATA中进行处理(视情况而定)
  • 相关阅读:
    this.get_element .style为空或不是对象
    在server2008R2的IIS7中调试asp程序遇到的错误
    Server.Transfer 在两个窗体之间传递参数用法
    页面事务处理 ContextUtil.SetComplete(); 没有 MTS 对象上下文
    VS2008切换设计视图卡死 停止响应
    javascript对象小结
    [JavaScript] 最低公用标准的浏览器文档对象层次
    Linq 此提供程序只支持对返回实体或投影(包含所有标识列)的有序查询使用 问题的解决
    [Design] Factory Pattern
    [Database] SqlServer: Linq to Sql THE DATACONTEXT Change Processing
  • 原文地址:https://www.cnblogs.com/IS2120/p/6745961.html
Copyright © 2011-2022 走看看