473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

XMLHTTPRequest with Xpath is not working

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><Princip alPWD /><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..
Nov 18 '05 #1
0 1490

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: jason.lucey | last post by:
Hi, I need some help figuring this out. I cannot get the xmlhttprequest object to return responseXML or getAllResponseHeaders. responseText works fine, but i'd rather use xPath than regular...
2
by: dx27s | last post by:
Hi all, I'm working with the XMLHttpRequest object. I receive the following error message: "Permission denied to call method XMLHttpRequest.open" This occurs in Firefox only. IE works fine. ...
0
by: Bravo | last post by:
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....
20
by: chris.schwalm | last post by:
This is part II of this <a...
14
by: Mat| | last post by:
Hello :-) I am learning XPath, and I am trying to get child nodes of a node whose names do *not* match a given string, e.g : <dummy> <example> <title>Example 1</title> <body>this is an...
1
by: CptDondo | last post by:
I am working on an embedded platform. I have php4 installed along with libxml, so I have working DOMXML and xpath stuff... But I can't figure out how to use it. I am trying to get the base...
1
by: NorbertH | last post by:
Hi! After sending a request to a server via XMLHttpRequest and receiving a response, I assign an incoming XML from a server via var root = request.responseXML.documentElement; to the...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
3
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
Hi; We have a TreeView that represents an xml file (or it's schema is a more accurate statement). We want to have a double click on a node in the tree generate the XPath to get to that node. ...
6
by: Patrick Nolan | last post by:
I'm working on cross-platform portability of some javascript. My Macintosh testing platform is rather old. It has Safari 1.3.2 and Internet Explorer 5.2. I got Safari working, but now IE is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.