473,387 Members | 1,420 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,387 software developers and data experts.

How can I parse this XML file,

Sam
Hi Everybody,
I'm using C# and System.XML and can parse XML files like this:

<LogIn>Yes</LogIn>

<Name>DB_MAGUser</Name>

but I've been asked to parse and work with a XML file that looks like this:

<entry Active="NO"/>

<entry LogIn="Yes"/>

and I can not parse this one, First of all, can you tell me which one is
witch? are they different version of XML? how they call
the second one?
than if I want to work with second one which class I have to use to be able
to parse it?

Thank you in advance - Sam

Feb 20 '06 #1
3 1449
Hi Sam,

I see you need a primer on XML and so my first suggestion is to read up
a tutorial on XML Or a good book.

http://www.w3schools.com/xml/default.asp has a good one.

To answer your questions,

1. They are NOT a different form of XML, they just contain different
types of XML elements. The second type contains XML attributes. (Think
of them as similar to HTML Tag attributes.)

2. What exactly do you mean by "Parse a file" ? What is it that you
intend to do with the file ?

3. Using C#, an XmlElement has a GetAttribute method that you can use
to retrieve the value of the attribute :

Dim myElem as XmlElement = doc.DocumentElement

if (myElem.HasAttribute("Active"))
Dim status as String = root.GetAttribute("Active")
Console.WriteLine(status)
end if

Regards,

Cerebrus.

Feb 20 '06 #2
Sam
Hi Cerebrus;
Thanks a lot for your response, you are right I need more study on that and
I already started that,
I also used XmlElement that you mentioned and with a bit work manage to get
Elements and
show them on a web page,

The all work that I'm going to do is opening an XML file that is a
Configuration file (Something like an ini file)for another
program(Program-2), extract all configuration parasites(about 3*10
paramiters) show them in a web
page and let web users edit/change those parameters then save the XML file
again, so the Program-2 read this configuration file again next time when it
startup, I don't work on that Program-2 but I have to get an agrement with
the programmar of that program and he is not good on XML either but he
sugest the second XML file because it was
supported on his progamming language (Ace) ,

Can you please give me your suggestion, do you think an XML file with
Elements is a good
way for keeping configuration information, and would be simple editing that
XML file for me later, or is there a
better format that is more supported in ASP.NET/C# ,

Thank you in advance - Sam
"Cerebrus99" <zo*****@sify.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Hi Sam,

I see you need a primer on XML and so my first suggestion is to read up
a tutorial on XML Or a good book.

http://www.w3schools.com/xml/default.asp has a good one.

To answer your questions,

1. They are NOT a different form of XML, they just contain different
types of XML elements. The second type contains XML attributes. (Think
of them as similar to HTML Tag attributes.)

2. What exactly do you mean by "Parse a file" ? What is it that you
intend to do with the file ?

3. Using C#, an XmlElement has a GetAttribute method that you can use
to retrieve the value of the attribute :

Dim myElem as XmlElement = doc.DocumentElement

if (myElem.HasAttribute("Active"))
Dim status as String = root.GetAttribute("Active")
Console.WriteLine(status)
end if

Regards,

Cerebrus.

Feb 21 '06 #3
Hi Sam,

Firstly, XML is an excellent format for storing configuration settings.
Even VS.NET stores many of it's configuration files in the XML format.
It's is one of the most inter-operable formats for Data interchange.

However, it basically depends on your comfort level with XML and the
size of the config. file. If you meant 3^10 (59,049) parameters, then,
that's quite a large file in my opinion. If you meant 3x10 (30)
parameters, then it's easily manageable.

As others more experienced than me have told me in these forums, when
working with large XML files, performance issues can become a major
consideration.

Also, reading and editing nodes of an XML file will involve a sound
knowledge of not only XML itself, but it's associated technologies,
like DOM and XPath.

So, to summarize, go ahead and use XML, if you feel comfortable with
it, and if performance and speed are not among your highest priorities.
If not, you might consider using flat files (simple text based files)
or a database. XML is equally well supported in .NET as are other text
files.

You might check out this site :
http://xml.silmaril.ie/basics/whatisxml/ maintained by Peter Flynn,
which has some very nice and useful FAQ's.

Hope this helps,

Regards,

Cerebrus.

Feb 21 '06 #4

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

Similar topics

1
by: chuck amadi | last post by:
By the way list is there a better way than using the readlines() to > > >parse the mail data into a file , because Im using > > >email.message_from_file it returns > > >all the data i.e reads one...
22
by: Ram Laxman | last post by:
Hi all, I have a text file which have data in CSV format. "empno","phonenumber","wardnumber" 12345,2234353,1000202 12326,2243653,1000098 Iam a beginner of C/C++ programming. I don't know how to...
3
by: slylos | last post by:
I've got a section of code in my app that keeps track of how much time an employee has accrued, which equals out to 1.33 days of PTO per month. I'm trying to store the time accrued so far in an...
6
by: trevor | last post by:
Incorrect values when using float.Parse(string) I have discovered a problem with float.Parse(string) not getting values exactly correct in some circumstances(CSV file source) but in very similar...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
11
by: Peter Pei | last post by:
One bad design about elementtree is that it has different ways parsing a string and a file, even worse they return different objects: 1) When you parse a file, you can simply call parse, which...
2
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString",...
6
by: =?Utf-8?B?RGF2aWRN?= | last post by:
Hello, I have an XML file generated from a third party application that I would like to parse. Ideally, I plan on having a windows service setup to scan various folders for XML files and parse the...
5
by: goldtech | last post by:
SAX XML Parse Python error message Hi, My first attempt at SAX, but have an error message I need help with. I cite the error message, code, and xml below. Be grateful if anyone can tell me...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...

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.