Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 20th, 2006, 07:45 PM
Sam
Guest
 
Posts: n/a
Default How can I parse this XML file,

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



  #2  
Old February 20th, 2006, 09:15 PM
Cerebrus99
Guest
 
Posts: n/a
Default Re: How can I parse this XML file,

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.

  #3  
Old February 21st, 2006, 03:05 AM
Sam
Guest
 
Posts: n/a
Default Re: How can I parse this XML file,

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" <zorg007@sify.com> wrote in message
news:1140469454.705553.59990@o13g2000cwo.googlegro ups.com...[color=blue]
> 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.
>[/color]


  #4  
Old February 21st, 2006, 09:55 AM
Cerebrus99
Guest
 
Posts: n/a
Default Re: How can I parse this XML file,

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.

 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles