开发者

Reading xmldata through parser

Hello Everyone I am Reading Data as a xmlElemet through parser

I am getting error Like..'\b', hexadecimal value 0x08, is an invalid character

I Read this string.. Thanks..

        XElement xParser = null;
            string sPwd = null;
            string sKey1 = null;
            string sKey2 = null;
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            string soutxml = "";

            soutxml = encoding.GetString(sEncData);
           xParser 开发者_高级运维= XElement.Parse(soutxml);

        IEnumerable<XElement> elemsValidations =
              from el in xParser.Elements("EmailPwd")
             select el;

        foreach (XElement elemValidation in elemsValidations)
        {
            sPwd = elemValidation.Element("EncPwd").Value;
            sKey1 = elemValidation.Element("Key1").Value;
            sKey2 = elemValidation.Element("Key2").Value;
        }

            byte[] Key1 = encoding.GetBytes(sKey1);
            byte[] Key2 = encoding.GetBytes(sKey2);
            byte[] Data = encoding.GetBytes(sPwd);

            // Decrypt the buffer back to a string.
            string Final = DecryptTextFromMemory(Data, Key1, Key2);

            return Final;

This data is actual data output..

- <EmailPwd>
- <EncPwd>
- <![CDATA[ ?????@]Z
  ]]> 
  </EncPwd>
- <Key1>
- <![CDATA[ ~??s????E&?3??2?3I?????
  ]]> 
  </Key1>
- <Key2>
- <![CDATA[ ???h?6
  ]]> 
  </Key2>
  </EmailPwd>


Your data appears to have a char 0x08 in it. According to XML specification this is not valid XML so the parser is correct in raising an error

You have to change the data to be valid XML - by changing with the invalid characters. and /or asking the supplier of the data to provide XML which they are not currently doing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜