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中进行处理(视情况而定)
  • 相关阅读:
    虚拟化、云计算与超融合的简单总结
    期货量化总结与思考
    易盛内外通用版交易API转websocket
    门诊叫号系统系列-1.语音叫号 .net c#
    六线顺上黑马选股和切割线选股法该如何操作?
    我的总结--强势股的短线战法精髓
    MACD头肩顶/底 = 驱动五浪
    有效突破的三三原则
    5日均线--攻击线
    10日均线--操盘线
  • 原文地址:https://www.cnblogs.com/IS2120/p/6745961.html
Copyright © 2011-2022 走看看