开发者

Encoding of data from XML file and ASP.NET textbox

I'm trying to compare a string obtained through a textbox and a string read from an XML file. The XML file is as given below.

<?xml version="1.0" encoding = "UTF-8" ?>

<cars>

   <car>

       <name>

           Honda

       </name>

   </car>

</cars>

The trouble is that when I compare the text "Honda" read from the XML file and the text obtained from the textbox, the comparison fails. I checked the length of both texts. The length of the text from the textbox is correctly shown while that from the XML file is 4 times larger. I'm wondering whether this has got somethi开发者_开发知识库ng to do with the encoding of the texts. I'm not sure how we can make both text in the same format.

Any help would be great!

Thanks,


With the XML that you pasted the value of name looks like \n Honda \n to me - remove all the white space and newlines from within your <name> tag and they should be identical.

Remember that all characters that are not markup will be passed to the application when you parse a node - in this case this includes the white space characters that are difficult to see and weed out sometimes, but they are there.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜