Xml element serialize problem

G

Guest

Hello,
I've got some problem with pass Xml element that contains special characters
( through ) via Web-service.
For example -
Server:
[WebMethod]

public XmlElement HelloWorld()

{

XmlDocument doc = new XmlDocument();

doc.LoadXml("<a></a>");

return doc.DocumentElement;

}



Client:

Service1 s = new Service1();

s.HelloWorld();

and I've got such exception


System.InvalidOperationException: There is an error in XML document (1,
295). --
-> System.Xml.XmlException: '', hexadecimal value 0x02, is an invalid
character
.. Line 1, position 300.
at System.Xml.XmlScanner.ScanHexEntity()
at System.Xml.XmlTextReader.ParseBeginTagExpandCharEntities()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlLoader.LoadChildren(XmlNode parent)
at System.Xml.XmlLoader.LoadElementNode()
at System.Xml.XmlLoader.LoadCurrentNode()
at System.Xml.XmlLoader.ReadCurrentNode(XmlDocument doc, XmlReader
reader)
at System.Xml.XmlDocument.ReadNode(XmlReader reader)
at System.Xml.Serialization.XmlSerializationReader.ReadXmlNode(Boolean
wrappe
d)

How can I fix this problem??
Thank you.
 
J

Javier G. Lozano

Could you list the characters you're trying to send back to the client?
The more we know, the easier it is to help you out.
 
G

Guest

For example I'm trying this character '?' , but I think never mind what
character exactly...
 
J

Javier G. Lozano

I'm sorry, I'm having a hard time understanding you. Do you have
another character that's easier to work with?
 
G

Guest

I'm trying to send any special character in XmlElement, for example, &#x2
via Web-Service.
AFAIK each special character has been encoded in XML

ms-help://MS.MSDNQTR.2004APR.1033/cpguide/html/cpconSpecialCharacterConversionWhenWritingXMLContent.htm

in server side it's ok (special characters are encoded), but when client
retrieve XmlElement, I think, client try to decode special characters from
&#x2 and replace them to one symbol , of course XML can't contains
characters such as - smiling face character - and I've got exception.
What I can do in this situation??


See below...

Javier G. Lozano said:
Are your characters listed in this link:
http://www.w3.org/TR/REC-html40/sgml/entities.html ?
I didn't find it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top