Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > xml to plaintext ? newbie

Reply
Thread Tools

xml to plaintext ? newbie

 
 
david.vantongerloo
Guest
Posts: n/a
 
      10-31-2006
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 ?


 
Reply With Quote
 
 
 
 
Morten Wennevik
Guest
Posts: n/a
 
      11-01-2006
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]
 
Reply With Quote
 
 
 
 
david.vantongerloo
Guest
Posts: n/a
 
      11-01-2006
realy Thanks....



"Morten Wennevik" <> wrote in message
news...
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]


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PIX: show / copy pre-shared key in plaintext nemo@weathersong.net Cisco 8 11-08-2006 04:09 PM
How do i load a plaintext file in a aspx website / newbie david.vantongerloo ASP .Net 2 10-27-2006 10:35 PM
Packt published an article about xtopdf - creating PDF from PlainText, DBF, CSV, TDV, and XLS Data vasudevram Python 0 08-19-2006 01:38 PM
Crypto.PublicKey.RSA.error: Plaintext too large Ajay Brar Python 5 08-04-2004 12:05 PM
Re: plaintext FatBlokeOnBikepins@pinsmother-truckers.co.uk HTML 3 06-23-2003 07:35 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57