473,406 Members | 2,843 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,406 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 1494

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.