Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
C#
string a = null;
a = getresponsefromserver(stringrequest);//This function returns the response xml
System.Xml.XmlDocument oXmlDocument = new System.Xml.XmlDocument();
oXmlDocument.Load(a); // here is the place where error occurs


the problem here is, I am getting the desired response in a.
but when I try to load it into a xmldocument it show illegal characters found.
I have made sure that response xml is in right format.
Posted
Updated 12-May-13 21:24pm
v3
Comments
Ameen Sherif 13-May-13 2:49am    
getresponsefromserver() functions returns the requested xml
Mohammed Hameed 13-May-13 3:04am    
Can u provide the code block for getresponsefromserver() function?

1 solution

Change your line of code from:
C#
oXmlDocument.Load(a);

to:
C#
oXmlDocument.LoadXml(a);

XmlDocument.Load()[^] is used to load XML either from a stream, TextReader, path/URL, or XmlReader.
XmlDocument.LoadXml()[^] is used to load the XML contained within a string variable

Good luck,
OI
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900