G
Guest
Hi
I am trying to call a web page to get xml response back using xmlWebRequest and HTTPWebResponse classes. After getting the response, I am loading it in to a xmlDocument for further processing. I am using XPath to verify and get results from XML Document.
Problem is, when I use the Xpath expression, eventhough document has value in it, it returns null object. When I checked the response using xml document's outerXML property, I found that each element has "\" charecters in front of it and "\ charecter at the end
Anybody has any idea of which kind of encoding should I use to eleiminate this problem?? Attaching code for reference
Thanks in advance for help.
Brav
Snippet =================
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(URL)
objRequest.Method = "POST"
objRequest.ContentLength = sRequest.Length
objRequest.ContentType = "application/x-www-form-urlencoded"
tr
myWriter = new StreamWriter(objRequest.GetRequestStream())
myWriter.Write(sRequest.ToString())
catch (Exception e)
ExceptionManager.Publish(e)
return null
finally
myWriter.Close()
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse()
XmlTextReader xr = new XmlTextReader(objResponse.GetResponseStream());
//Validate XML content and get resul
XmlDocument xDoc =new XmlDocument(); //declare an XML document objec
xDoc.Load(xr); //load document with resul
xr.Close(); // Close and clean up the StreamReade
string sXPath="//Response/Status/StatusCode"
XmlNode xResult
XmlNamespaceManager xnm=new XmlNamespaceManager(xDoc.NameTable)
xResult = xDoc.SelectSingleNode(sXPath,xnm);//Query documen
if ((xResult!= null) && (xResult.InnerText.ToLower()=="0")) //here it fails to load valu
//process values of this documen
//XML I am getting
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><fiAPI xmlns=\"http://devivwb1.bhcsecurities.com/schema/fiAPI/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://devivwb1.bhcsecurities.com/schema/fiAPI/ http://devivwb1.bhcsecurities.com/schema/fiAPI/user_profile/fiUserProfile.xsd\"><fiHeader Version=\"\"><Service Version=\"\" Name=\"UserProfile\"><DateTime>2003-07-30T09:30:47-05:00</DateTime><UUID /></Service><Security><AuthenticationMaterial><PrincipalPWD /><SignedToken>612d7b37614b39467264</SignedToken></AuthenticationMaterial><PrincipalID /></Security><Client Version=\"\"><VendorID /><AppID /><OrgID /><SessionID /></Client><DataSource><URI>http://10.242.213.205/fpr/</URI></DataSource></fiHeader><Response TypeOfResponse=\"UserProfile\"><Status><StatusCode>0</StatusCode><Severity /></Status><UserProfile><IbList><IB ibCode=\"BHC\" ibName=\"\" /></IbList><OfficeList /></UserProfile><UserPrivileges><Privilege privName=\"EDOCUMENT\" privValue=\"Y\" context=\" Boolean\" />
//return xml is a big xml this is just a part for reference..
I am trying to call a web page to get xml response back using xmlWebRequest and HTTPWebResponse classes. After getting the response, I am loading it in to a xmlDocument for further processing. I am using XPath to verify and get results from XML Document.
Problem is, when I use the Xpath expression, eventhough document has value in it, it returns null object. When I checked the response using xml document's outerXML property, I found that each element has "\" charecters in front of it and "\ charecter at the end
Anybody has any idea of which kind of encoding should I use to eleiminate this problem?? Attaching code for reference
Thanks in advance for help.
Brav
Snippet =================
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(URL)
objRequest.Method = "POST"
objRequest.ContentLength = sRequest.Length
objRequest.ContentType = "application/x-www-form-urlencoded"
tr
myWriter = new StreamWriter(objRequest.GetRequestStream())
myWriter.Write(sRequest.ToString())
catch (Exception e)
ExceptionManager.Publish(e)
return null
finally
myWriter.Close()
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse()
XmlTextReader xr = new XmlTextReader(objResponse.GetResponseStream());
//Validate XML content and get resul
XmlDocument xDoc =new XmlDocument(); //declare an XML document objec
xDoc.Load(xr); //load document with resul
xr.Close(); // Close and clean up the StreamReade
string sXPath="//Response/Status/StatusCode"
XmlNode xResult
XmlNamespaceManager xnm=new XmlNamespaceManager(xDoc.NameTable)
xResult = xDoc.SelectSingleNode(sXPath,xnm);//Query documen
if ((xResult!= null) && (xResult.InnerText.ToLower()=="0")) //here it fails to load valu
//process values of this documen
//XML I am getting
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><fiAPI xmlns=\"http://devivwb1.bhcsecurities.com/schema/fiAPI/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://devivwb1.bhcsecurities.com/schema/fiAPI/ http://devivwb1.bhcsecurities.com/schema/fiAPI/user_profile/fiUserProfile.xsd\"><fiHeader Version=\"\"><Service Version=\"\" Name=\"UserProfile\"><DateTime>2003-07-30T09:30:47-05:00</DateTime><UUID /></Service><Security><AuthenticationMaterial><PrincipalPWD /><SignedToken>612d7b37614b39467264</SignedToken></AuthenticationMaterial><PrincipalID /></Security><Client Version=\"\"><VendorID /><AppID /><OrgID /><SessionID /></Client><DataSource><URI>http://10.242.213.205/fpr/</URI></DataSource></fiHeader><Response TypeOfResponse=\"UserProfile\"><Status><StatusCode>0</StatusCode><Severity /></Status><UserProfile><IbList><IB ibCode=\"BHC\" ibName=\"\" /></IbList><OfficeList /></UserProfile><UserPrivileges><Privilege privName=\"EDOCUMENT\" privValue=\"Y\" context=\" Boolean\" />
//return xml is a big xml this is just a part for reference..