473,320 Members | 2,117 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,320 software developers and data experts.

looking for a very basic XML read example

Hi all,

I'm trying to read a particular node value from an XML file, but I've
done some searching on the net and there doesn't seem to be a very basic
example.

Basically here's what I want to do...

- In my web.config I have:

<configuration>
<appSettings>
<add key="constring" value="blah" />
</appSettings>

....

- I want to retrieve the value of the key "constring"
I'm performing this from a dll so I can't access this value using
ConfigurationSettings.AppSettings("constring")

(plus I want to learn how to read xml files)
I'm sure this is only about 4 lines of code, anyone got any samples of
how to do this?

Much thanks,
Peter
--

fiddlewidawiddum
Nov 15 '06 #1
4 1595
You want to do an XPath SelectSingleNode - you can do this from an
XmlDocument or an XPathNavigator from the XPathDocument (don't remember if
you can go direct).

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


"Stimp" wrote:
Hi all,

I'm trying to read a particular node value from an XML file, but I've
done some searching on the net and there doesn't seem to be a very basic
example.

Basically here's what I want to do...

- In my web.config I have:

<configuration>
<appSettings>
<add key="constring" value="blah" />
</appSettings>

....

- I want to retrieve the value of the key "constring"
I'm performing this from a dll so I can't access this value using
ConfigurationSettings.AppSettings("constring")

(plus I want to learn how to read xml files)
I'm sure this is only about 4 lines of code, anyone got any samples of
how to do this?

Much thanks,
Peter
--

fiddlewidawiddum
Nov 15 '06 #2

You're in luck.

See
http://www.eggheadcafe.com/forums/Fo...=85647&INTID=6

and give a hollar out to Peter Bromberg ..


"Stimp" <re*@spumco.comwrote in message
news:sl****************@murphy.redbrick.dcu.ie...
Hi all,

I'm trying to read a particular node value from an XML file, but I've
done some searching on the net and there doesn't seem to be a very basic
example.

Basically here's what I want to do...

- In my web.config I have:

<configuration>
<appSettings>
<add key="constring" value="blah" />
</appSettings>

...

- I want to retrieve the value of the key "constring"
I'm performing this from a dll so I can't access this value using
ConfigurationSettings.AppSettings("constring")

(plus I want to learn how to read xml files)
I'm sure this is only about 4 lines of code, anyone got any samples of
how to do this?

Much thanks,
Peter
--

fiddlewidawiddum

Nov 15 '06 #3
On Wed, 15 Nov 2006 sloan <sl***@ipass.netwrote:
>
You're in luck.

See
http://www.eggheadcafe.com/forums/Fo...=85647&INTID=6

and give a hollar out to Peter Bromberg ..

wow.. I need all that code just to do a simple XML file scan for one
node?

"Stimp" <re*@spumco.comwrote in message
news:sl****************@murphy.redbrick.dcu.ie...
>Hi all,

I'm trying to read a particular node value from an XML file, but I've
done some searching on the net and there doesn't seem to be a very basic
example.

Basically here's what I want to do...

- In my web.config I have:

<configuration>
<appSettings>
<add key="constring" value="blah" />
</appSettings>

...

- I want to retrieve the value of the key "constring"
I'm performing this from a dll so I can't access this value using
ConfigurationSettings.AppSettings("constring")

(plus I want to learn how to read xml files)
I'm sure this is only about 4 lines of code, anyone got any samples of
how to do this?

Much thanks,
Peter
--

fiddlewidawiddum


--

fiddlewidawiddum
Nov 15 '06 #4
On Wed, 15 Nov 2006 David Thielen <th*****@nospam.nospamwrote:
You want to do an XPath SelectSingleNode - you can do this from an
XmlDocument or an XPathNavigator from the XPathDocument (don't remember if
you can go direct).
Hi David,

So basically the code would be something like...
XmlDocument oDoc = new XmlDocument();

oDoc.Load("web.config");

sConnstring = oDoc.SelectSingleNode("//constring");

?

That's 3 lines.. so I'm close to my 4 line estimate :)
--

fiddlewidawiddum
Nov 15 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Leif K-Brooks | last post by:
Has anyone ever tried implementing a simple unstructured BASIC dialect in Python? I'm getting interested in language implementation, and looking at a reasonably simple example like that could be...
7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
4
by: Frank Einstein | last post by:
Looking for a tool that can edit an XML file in a browser. The basic requirement is that the XML file is rendered as an HTML form with editable fields (including add/delete, preferably in...
12
by: Charles Law | last post by:
Hi guys A bit of curve ball here ... I have a document (Word) that contains a series of instructions in sections and subsections (and sub-subsections). There are 350 pages of them. I need to...
14
by: luis | last post by:
Are basic types (int, long, ...) objetcs or not? I read that in C# all are objects including basic types, derived from Object class. Then in msdn documentation says that boxing converts basic...
1
by: marklinehan | last post by:
Hi, my name is Mark Linehan. About 20 years ago or so I started learning how to program on the Commodore 64 computer (anyone remember those?) heheheh. I taught myself basic on this little machine...
6
by: Ray Cassick \(Home\) | last post by:
I am looking for a control that displays simple HTML text (just basic tags, not active content needed). I know I can use the IE ActiveX control but really want to stay away from the headaches if...
6
by: bambooforest | last post by:
Hi all, I'm from a Linguistics background and am new(er) to programming. Could someone recommend a book or resource that teaches programming aspects with Python? Python I hear is a very...
17
by: sloan | last post by:
I found these (2 links below). Does anyone know of any (neutral) reference sites for this kind of information? http://www.itjungle.com/tug/tug121406-story03.html Microsoft's Visual Basic 6 and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.