XMLHTTPRequest with Xpath is not working

Discussion in 'ASP .Net' started by =?Utf-8?B?QnJhdm8=?=, Apr 1, 2004.

  1. 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..
     
    =?Utf-8?B?QnJhdm8=?=, Apr 1, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anna
    Replies:
    0
    Views:
    573
  2. Unknown User

    XMLHttpRequest not working as expected

    Unknown User, Feb 7, 2005, in forum: Javascript
    Replies:
    2
    Views:
    98
    Unknown User
    Feb 8, 2005
  3. xmlhttprequest not working

    , Sep 21, 2005, in forum: Javascript
    Replies:
    4
    Views:
    174
  4. Replies:
    1
    Views:
    121
    Laurent Bugnion
    Jun 9, 2006
  5. Xandor Leahte

    XPath, XMLHttpRequest and parsing DOM

    Xandor Leahte, Aug 8, 2011, in forum: Javascript
    Replies:
    4
    Views:
    1,168
    Martin Honnen
    Aug 12, 2011
Loading...

Share This Page