473,770 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get some value from XML file

Hello.
I have XML file like this:

=============== =============== ============
<?xml version="1.0" encoding="utf-8" ?>
<Language>
<English>
<Captions>
<Name>Some caption</Name>
</Captions>
<Messages>
<Name>Some message</Name>
</Messages>
</English>
</Language>
=============== =============== ============

I want to read from this XML file "Some message" which is on
Language\Englis h\Messages section.
How can I do this?
Can anybody show me some example?

Thank you.
Nov 16 '05 #1
3 28888
Hi David,

using System.Xml

Construct xml document using

XmlDocument doc = new XmlDocument;

Load document

doc.Load(file);

Now adress the text node

XmlNode node = doc.SelectSingl eNode("Language/English/Messages/Name/text()");

then read the value into a string

string foo = node.Value;

Use XPath expressions in the selectSingleNod e function!

Regards Jesper,Denmark

"David" wrote:
Hello.
I have XML file like this:

=============== =============== ============
<?xml version="1.0" encoding="utf-8" ?>
<Language>
<English>
<Captions>
<Name>Some caption</Name>
</Captions>
<Messages>
<Name>Some message</Name>
</Messages>
</English>
</Language>
=============== =============== ============

I want to read from this XML file "Some message" which is on
Language\Englis h\Messages section.
How can I do this?
Can anybody show me some example?

Thank you.

Nov 16 '05 #2
Than you very much for helping.
I have one more question please:
=============== =============== =========
<?xml version="1.0" encoding="utf-8" ?>
<Languages>
<Language Lnag="English" />
<Captions>
<Name>Some English caption</Name>
</Captions>
<Language>
<Language Lnag="German" />
<Captions>
<Name>Some German caption</Name>
</Captions>
<Language>
</Languages>
=============== =============== =========
Can you show me please how can I get "Some English caption"?

Thank you?
"Jesper" <Je****@discuss ions.microsoft. com> wrote in message
news:2C******** *************** ***********@mic rosoft.com...
Hi David,

using System.Xml

Construct xml document using

XmlDocument doc = new XmlDocument;

Load document

doc.Load(file);

Now adress the text node

XmlNode node =
doc.SelectSingl eNode("Language/English/Messages/Name/text()");

then read the value into a string

string foo = node.Value;

Use XPath expressions in the selectSingleNod e function!

Regards Jesper,Denmark

"David" wrote:
Hello.
I have XML file like this:

=============== =============== ============
<?xml version="1.0" encoding="utf-8" ?>
<Language>
<English>
<Captions>
<Name>Some caption</Name>
</Captions>
<Messages>
<Name>Some message</Name>
</Messages>
</English>
</Language>
=============== =============== ============

I want to read from this XML file "Some message" which is on
Language\Englis h\Messages section.
How can I do this?
Can anybody show me some example?

Thank you.

Nov 16 '05 #3
Yep!

XmlNode node =
doc.SelectSingl eNode("Language s/Language[@Lnag='English']/Captions/Name/text()");

string foo = node.Value;

the [] brackets serve as filters setting a condition. @ indicate an attribute.

best regards Jesper
"David" wrote:
Than you very much for helping.
I have one more question please:
=============== =============== =========
<?xml version="1.0" encoding="utf-8" ?>
<Languages>
<Language Lnag="English" />
<Captions>
<Name>Some English caption</Name>
</Captions>
<Language>
<Language Lnag="German" />
<Captions>
<Name>Some German caption</Name>
</Captions>
<Language>
</Languages>
=============== =============== =========
Can you show me please how can I get "Some English caption"?

Thank you?
"Jesper" <Je****@discuss ions.microsoft. com> wrote in message
news:2C******** *************** ***********@mic rosoft.com...
Hi David,

using System.Xml

Construct xml document using

XmlDocument doc = new XmlDocument;

Load document

doc.Load(file);

Now adress the text node

XmlNode node =
doc.SelectSingl eNode("Language/English/Messages/Name/text()");

then read the value into a string

string foo = node.Value;

Use XPath expressions in the selectSingleNod e function!

Regards Jesper,Denmark

"David" wrote:
Hello.
I have XML file like this:

=============== =============== ============
<?xml version="1.0" encoding="utf-8" ?>
<Language>
<English>
<Captions>
<Name>Some caption</Name>
</Captions>
<Messages>
<Name>Some message</Name>
</Messages>
</English>
</Language>
=============== =============== ============

I want to read from this XML file "Some message" which is on
Language\Englis h\Messages section.
How can I do this?
Can anybody show me some example?

Thank you.


Nov 16 '05 #4

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

Similar topics

3
8899
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns a empty value instead of returning the browser type. Here is the line which i am using in my code and from manual: <?php echo $_SERVER; ?>
7
5076
by: matthew_carver | last post by:
Hello, I have an ASP page that loops through a SQL Server 2000 table, then downloads an Excel sheet the users can save, etc. Works fine, except, I see that in one particular "comments" field the Excel sheet returns a #VALUE! error in the cell when there is a large amount of text. I've looked through the MSKB, MSDN and many ng posts to see if there is a workaround or solution to this, including looking at the xlWorksheet properties. Is...
2
28576
by: Matt | last post by:
If I do the following, the browse text box still cannot see C:/hello world/test.txt. <input type="file" name="fileName" value="C:/hello world/test.txt" size=80> Any ideas? and workarounds to this problem? thanks!!
5
3229
by: Robert Oschler | last post by:
I am converting a Perl script over to "C" for a potential open source project. I need some open source "C" code that will give me the same functionality of a Perl Style associative array: someArray = 6; I know I can't get the same syntactic sugar as Perl offers, with the usage of a string as the array key surrounded by square brackets. I just want the general functionality, that's all. That is, a data container that will maintain...
6
2247
by: melanieab | last post by:
Hi, Easy question. It seems to me that I'm following the examples correctly, but apparently I'm not. I'm trying to retrieve the data from a row called "row" and a column called "File". This is what I have: (xFile is the int value in column File and tCat is the table) First I try: xFile = int.Parse((tCat.Rows).ToString()); Another example I found:
2
2578
by: Bilal | last post by:
Hello, I'm stuck on this problem for quite some time and hope somebody would be able to guide me. Basically, I need to populate a large number of "template" XML files which have all elements/attributes etc. defined but the values in these elements/attributes might be blank or place holders, as two examples below: Example - File type 1
1
3592
Fary4u
by: Fary4u | last post by:
Hi Guys i'm trying to upload a file, i've tried 3 different methods but still not work out i don't know how to over come this problem hidden file value, multiple form or popup uploading. 1- <SCRIPT TYPE="text/javascript"> function popupform(myform, windowname)
0
1541
by: Fredrik Lundh | last post by:
maurizio wrote: What kind of file is it? Did you pick numpy because you want to do matrix operations (beyond just finding a maximum value), or was it just the first thing you stumbled upon when researching the problem? A simple pattern for finding the maximum value in a file, using only plain Python code, is:
1
3373
by: maurizio | last post by:
thank you for your answer actually i've to do some statistics (maximum,minimum,mean,standard deviation,....) of a file of data in which each column is a particular type of data. (the file is a tab separated value). I was trying to do this by using python (usually i work with fortran or bash, but i'm learning python), that the reason why i tried to use numpy. Fredrik Lundh wrote:
0
1753
by: grego9 | last post by:
I have a bit of visual basic code in an excel spreadsheet that I need some help with. I am attempting to search a file called TO Cancellations2.xls for counterparty names and for each counterparty name that it finds that matches the list of counterparties on the "counterparties" sheet of a file called Time Option Template WIP.xls I want the whole line copied and pasted into a new excel worksheet that should have the counterparty name and then...
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7451
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
6710
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();...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
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.