Get/Post XML results from a single XML Field

Last post 07-02-2009 10:16 AM by solutionsville. 5 replies.

Sort Posts:

  • Get/Post XML results from a single XML Field

    06-30-2009, 1:45 PM
    • Member
      4 point Member
    • solutionsville
    • Member since 01-15-2008, 2:12 PM
    • Fort Worth, TX
    • Posts 10

     I am using a third party Web Service application that I can obtain a status from by navigating to a web address and port and I receive an XML result similar to this;

      <?xml version="1.0" encoding="UTF-8" ?>
    - <alwaysup-get-status-response>
    - <applications>
    - <application>
      <name>MyApp</name>
      <state>Running</state>
      </application>
      </applications>
      </alwaysup-get-status-response>
     
    I want to take the value of the <state></state> field and post it to cell of a table automatically when the web site is opened, and refreshed every 300 seconds.
     
    What is the best way to do this?
     
    Thanks!
     
    Brian
  • Re: Get/Post XML results from a single XML Field

    07-01-2009, 12:49 AM

    solutionsville:
     

    I want to take the value of the <state></state> field and post it to cell of a table automatically when the web site is opened, and refreshed every 300 seconds.
     
    What is the best way to do this?
     
    Thanks!
     
    Brian

    To read the value from node state u can use xmlDom or write a simple xslt which does xml to html transformation.

    Now if u want to update this value every 300 seconds then u have to write a schedular that runs every 300 seconds..then it calls this web service and does the autorefresh to ur UI.



    Please mark this post as Answer if it is of help to you!

    " You can't do anything about length of life, but sure you can do about depth of life..! "
  • Re: Get/Post XML results from a single XML Field

    07-01-2009, 7:00 AM

     XPathDocument doc = new XPathDocument("http://example.com/service");

    string state = doc.SelectSingleNode("always-up-get-status-response/applications/application/state").Value;

    Label1.Text = state;

    Put a Label control in your table cell and put the above code into the Page_Load handler.

     

    Martin Honnen --- MVP XML
    My blog
  • Re: Get/Post XML results from a single XML Field

    07-01-2009, 4:29 PM
    • Member
      4 point Member
    • solutionsville
    • Member since 01-15-2008, 2:12 PM
    • Fort Worth, TX
    • Posts 10

     

    The doc.SelectSingleNode item does not exist.

     

    With the XPathDocument doc declaration, it has five overloads. None of which are for selecting a specific node entry.

     

    Unless I am way off the mark.

     

    Thanks,

  • Re: Get/Post XML results from a single XML Field

    07-02-2009, 6:42 AM
    Answer

     I am sorry, SelectSingleNode is defined on XPathNavigator, not on XPathDocument so you need

    XPathDocument doc = new XPathDocument("http://example.com/service");
    
    string state = doc.CreateNavigator().SelectSingleNode("always-up-get-status-response/applications/application/state").Value;
    
    Label1.Text = state;
    


     

    Martin Honnen --- MVP XML
    My blog
  • Re: Get/Post XML results from a single XML Field

    07-02-2009, 10:16 AM
    • Member
      4 point Member
    • solutionsville
    • Member since 01-15-2008, 2:12 PM
    • Fort Worth, TX
    • Posts 10

     

    Thanks, that worked fine with the excpetion of I missed that the node item was not correct. Here is what it should look like;

     

    string state = doc.CreateNavigator().SelectSingleNode("alwaysup-get-status-response/applications/application/state").Value;

     

    Thanks for the help.

Page 1 of 1 (6 items)