xmldocument special character problem  
Author Message
Robert3234





PostPosted: XML and the .NET Framework, xmldocument special character problem Top

Hey guys,
I'm currently working on a project and I have to use the xmldocument object to handle my assorted XML needs. Throughout the course of the project, I've run into problem with the xmldocument, in that it doesn't accept a lot of characters, such as the I, etc. (mostly spanish letters). I was wondering if there's any way that I can change the encoding on the object or whatnot so that it will accept these characters. Thanks so much in advance!
-Robert

P.S. I posted this in the vb.net express forum, but to no avail



.NET Development26  
 
 
Oleg Tkachenko





PostPosted: XML and the .NET Framework, xmldocument special character problem Top

It accepts any characters valid for XML (anything except control characters). Show me how do you add text to the XmlDocument.


 
 
Robert3234





PostPosted: XML and the .NET Framework, xmldocument special character problem Top

well, the XML is being received from a server (which i don't think is the problem... so i'm just using the xmldoc.load ie:

dim doc as new xmldocument
doc.innerxml = sever_stuff


 
 
Robert3234





PostPosted: XML and the .NET Framework, xmldocument special character problem Top

Sorry for being unclear above ^^, I know the XML is valid because i'm also developing a macintosh client, and it can read the xml without a problem . That's not meant to be perjorative, just saying.


 
 
Oleg Tkachenko





PostPosted: XML and the .NET Framework, xmldocument special character problem Top

You should be using doc.LoadXml(server_stuff) instead of innerxml property.

Anyway, I'm still not sure what problem is...



 
 
Sergey Dubinets - MSFT





PostPosted: XML and the .NET Framework, xmldocument special character problem Top

Can you compose small repro, pleas

Create the XML string using StringBuilder with problematic characters and load this string to the XmlDocument.

Then post the code with the repro to the forum. Alternatively you can send me the xml file to .



 
 
Martin Honnen





PostPosted: XML and the .NET Framework, xmldocument special character problem Top

well, the XML is being received from a server (which i don't think is the problem... so i'm just using the xmldoc.load ie:

dim doc as new xmldocument
doc.innerxml = sever_stuff

If you receive XML from the server then you usually have a stream with the XML. Pass this stream directly to the XML APIs (e.g. XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(stream);), do not try to convert the stream to a string first and then use that string as that way if you don't check the encoding of the stream you get corrupt data.