xml to plaintext ? newbie

Discussion in 'ASP .Net' started by david.vantongerloo, Oct 31, 2006.

  1. hi ,

    How do i get hold on text in a XML file an insert it to an ASPX page.

    - <daily_statistics>
    <day>1162166400.000000</day>
    <user_total_credit>5859.155452</user_total_credit>
    <user_expavg_credit>81.830293</user_expavg_credit>
    <host_total_credit>491.812439</host_total_credit>
    <host_expavg_credit>46.814941</host_expavg_credit>
    </daily_statistics>


    All a need is this line only :
    <user_total_credit>5859.155452</user_total_credit>

    To Text :
    5859.155452

    How ?
     
    david.vantongerloo, Oct 31, 2006
    #1
    1. Advertising

  2. Hi David,

    Load your xml into an XmlDocument, then you can parse it using XPath
    queries and get the value you want. Storing your xml in a string variable
    called xml you can obtain your value like this

    XmlDocument doc = new XmlDocument();
    doc.LoadXml(xml);

    XmlNode node =
    doc.SelectSingleNode("daily_statistics/user_total_credit");
    string value = node.InnerText;

    "daily_statistics/user_total_credit" is the XPath query telling
    SelectSingleNode to get the first node matching this pattern

    value = 5859.155452


    On Tue, 31 Oct 2006 23:43:12 +0100, david.vantongerloo
    <> wrote:

    > hi ,
    >
    > How do i get hold on text in a XML file an insert it to an ASPX page.
    >
    > - <daily_statistics>
    > <day>1162166400.000000</day>
    > <user_total_credit>5859.155452</user_total_credit>
    > <user_expavg_credit>81.830293</user_expavg_credit>
    > <host_total_credit>491.812439</host_total_credit>
    > <host_expavg_credit>46.814941</host_expavg_credit>
    > </daily_statistics>
    >
    >
    > All a need is this line only :
    > <user_total_credit>5859.155452</user_total_credit>
    >
    > To Text :
    > 5859.155452
    >
    > How ?
    >
    >




    --
    Happy Coding!
    Morten Wennevik [C# MVP]
     
    Morten Wennevik, Nov 1, 2006
    #2
    1. Advertising

  3. realy Thanks....



    "Morten Wennevik" <> wrote in message
    news:eek:...
    Hi David,

    Load your xml into an XmlDocument, then you can parse it using XPath
    queries and get the value you want. Storing your xml in a string variable
    called xml you can obtain your value like this

    XmlDocument doc = new XmlDocument();
    doc.LoadXml(xml);

    XmlNode node =
    doc.SelectSingleNode("daily_statistics/user_total_credit");
    string value = node.InnerText;

    "daily_statistics/user_total_credit" is the XPath query telling
    SelectSingleNode to get the first node matching this pattern

    value = 5859.155452


    On Tue, 31 Oct 2006 23:43:12 +0100, david.vantongerloo
    <> wrote:

    > hi ,
    >
    > How do i get hold on text in a XML file an insert it to an ASPX page.
    >
    > - <daily_statistics>
    > <day>1162166400.000000</day>
    > <user_total_credit>5859.155452</user_total_credit>
    > <user_expavg_credit>81.830293</user_expavg_credit>
    > <host_total_credit>491.812439</host_total_credit>
    > <host_expavg_credit>46.814941</host_expavg_credit>
    > </daily_statistics>
    >
    >
    > All a need is this line only :
    > <user_total_credit>5859.155452</user_total_credit>
    >
    > To Text :
    > 5859.155452
    >
    > How ?
    >
    >




    --
    Happy Coding!
    Morten Wennevik [C# MVP]
     
    david.vantongerloo, Nov 1, 2006
    #3
    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. Re: plaintext

    , Jun 22, 2003, in forum: HTML
    Replies:
    3
    Views:
    1,101
    Headless
    Jun 23, 2003
  2. Ajay Brar
    Replies:
    5
    Views:
    809
    Peter Hansen
    Aug 4, 2004
  3. vasudevram
    Replies:
    0
    Views:
    321
    vasudevram
    Aug 19, 2006
  4. david.vantongerloo
    Replies:
    2
    Views:
    298
    david.vantongerloo
    Oct 27, 2006
  5. David Clymer

    Re: Crypto plaintext padding (SOLVED)

    David Clymer, May 6, 2007, in forum: Python
    Replies:
    0
    Views:
    421
    David Clymer
    May 6, 2007
Loading...

Share This Page