Represent space and tab in XML tag

前端 未结 8 1415

How to represent space and tab in XML tag. Is there any special characters for them to represent.

相关标签:
8条回答
  • 2020-11-29 05:48

    If you are talking about the issue where multiple and non-space whitespace characters are stripped specifically from attribute values, then yes, encoding them as character references such as 	 will fix it.

    0 讨论(0)
  • 2020-11-29 05:48

    Illegal XML Tag Name Characters can be encoded using Unicode UCS-2. This works very nicely. I am using it to create XML that gets turned into json (JPath is weak compared to XPath). Notice the handling of spaces, (, ) characters. Unicode UCS-2 Code Chart: http://www.columbia.edu/kermit/ucs2.html

            tag.Name = tag.Name.Replace(" ", "_x0020_");
            tag.Name = tag.Name.Replace("(", "_x0028_");
            tag.Name = tag.Name.Replace(")", "_x0029_");
    

    XML:

      <Internal_x0020_Chargeback_x0020_ID>{CHARGEBACKCODE}</Internal_x0020_Chargeback_x0020_ID>
      <Bill_x0020_To>{CHARGEBACKCODE}</Bill_x0020_To>
      <Operator_x0020_or_x0020_Directly_x0020_Responsible_x0020_Individual_x0020__x0028_DRI_x0029_>zzz@yyy.gov</Operator_x0020_or_x0020_Directly_x0020_Responsible_x0020_Individual_x0020__x0028_DRI_x0029_>
    

    transformed to json via json.net:

        "Internal Chargeback ID": "{CHARGEBACKCODE}",
        "Bill To": "{CHARGEBACKCODE}",
        "Operator or Directly Responsible Individual (DRI)": "xxx@yyy.gov",
    
    0 讨论(0)
提交回复
热议问题