473,800 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:

<configuratio n>
<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
ConfigurationSe ttings.AppSetti ngs("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
--

fiddlewidawiddu m
Nov 15 '06 #1
4 1610
You want to do an XPath SelectSingleNod e - 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_windwa rd_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:

<configuratio n>
<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
ConfigurationSe ttings.AppSetti ngs("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
--

fiddlewidawiddu m
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.com wrote in message
news:sl******** ********@murphy .redbrick.dcu.i e...
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:

<configuratio n>
<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
ConfigurationSe ttings.AppSetti ngs("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
--

fiddlewidawiddu m

Nov 15 '06 #3
On Wed, 15 Nov 2006 sloan <sl***@ipass.ne twrote:
>
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.com wrote in message
news:sl******** ********@murphy .redbrick.dcu.i e...
>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
ConfigurationS ettings.AppSett ings("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
--

fiddlewidawidd um


--

fiddlewidawiddu m
Nov 15 '06 #4
On Wed, 15 Nov 2006 David Thielen <th*****@nospam .nospamwrote:
You want to do an XPath SelectSingleNod e - 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.SelectSing leNode("//constring");

?

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

fiddlewidawiddu m
Nov 15 '06 #5

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

Similar topics

19
3228
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 pretty interesting.
7
9292
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. # No warranty express or implied for the accuracy, fitness to purpose
4
3613
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 accordance with with the document's XSD/DTD or other schema definition). I don't mind the actual form of this tool - could be implemented as a JSP/Servlet, ASP component, or browser plug-in for local or remote XML file access. Alternatively, it doesn't...
12
1659
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 translate these instructions into something that can be processed automatically, so I have used the Command pattern to set up a set of commands that correspond to the various instructions in the document.
14
2515
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 types in objects. But if they are objects why it´s need this conversion? Aren´t objects (basic types) like Java?
1
1592
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 to the point that there was nothing I could not do in basic on the 64 and started learning assembly language on it. I moved up to the Amiga, and dabbled in C. Then moved to an IBM 386. At that time I literally knew plain old MS-DOS version(s) of...
6
1315
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 I can. There has to be some type of lite control out there that can handle this. I am hacked off that the RTF control will not read HTML. RTF tags are WAY too much work for what I need to do. --
6
1374
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 appropriate language for handling text and language processing. I'm searching for a resource that examines programming from a case study like perspective. Such as, you're faced with problem of type X - and here's how you should look at it to break it...
17
1860
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 Visual Basic.NET language is taking a serious beating in the development cubicles of the United States and Canada. http://www.eweek.com/article2/0,1895,2065392,00.asp Study: Developer Use of Visual Basic Plummets
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10276
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10035
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7580
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.