Unable to parse value containing special character? Using sax parser

前端 未结 4 1208
逝去的感伤
逝去的感伤 2021-01-13 15:48

I am new to parsing field. I\'m trying to write a parser code but unable to get the value with respect to a particular tag that value contains ampersand(&).

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-13 16:42

    There are some characters in XML that must not appear in their literal form in an XML document, except when used as markup delimiters or within a comment, a processing instruction, or a CDATA section.
    List of characters and their corresponding entity or the numeric reference to replace :

    Original Character    XML entity replacement      XML numeric replacement
    
          "                     "                       "   
          <                     <                         <   
          >                     >                         >
          &                     &                        &
          '                     '                       '   
    

    you must replace above character in XML before you parse it.

    You may use CDATA Section for text that is not markup constitutes the character data of the document

提交回复
热议问题