parse xml


 
Thread Tools Search this Thread
Top Forums Programming parse xml
# 1  
Old 02-23-2004
Question parse xml

Hi,

I'm looking for an "easy" way to parse a xml file to a proper structure.

The xml looks like this
Quote:
<?xml version="1.0"?>
<tlt>
<tag attr="value" attr2="value" />
<tag2 attr="value" attr2="value" />
<tag attr="value" attr2="value" />
</tlt>
What shall I use? Does anybody has some example-code to share or some good links/book-references?

thx for any reply

-fe
# 2  
Old 02-23-2004
You didn't mention which library you are going to use.

For libxml2, samples at
http://www.xmlsoft.org/examples/index.html

For Apache Xerces C++, samples at
http://xml.apache.org/xerces-c/samples.html
# 3  
Old 02-24-2004
Quote:
Originally posted by cbkihong
You didn't mention which library you are going to use.
Thats because I didn't use any but I want to and because there are some I wanted to ask "what is a good lib to go for" Smilie

What do u suggest and why?

thx

-fe
# 4  
Old 02-24-2004
Personally I'm more fond of OO programming so I would go for Xerces, and I believe its API is easier to understand (and write), but libxml is more widely used in Open-Source community (mostly GTK-based programs).
# 5  
Old 02-26-2004
You could always write your own Smilie I did, in about 2600 lines of code. But I had no choice, I needed something that no other library wanted to give me, the ability to parse chunks of XML and piece them together into a final parse tree structure. That was plenty of fun...doesn't completed support the XML definition (doesn't support document type definition) but it works for simple stuff....
# 6  
Old 03-15-2004
Quote:
Posted by bin-doph
I'm looking for an "easy" way to parse a xml file to a proper structure.
The answer to your problem is SAX API.

SAX is low level parser you can use to parse
XML and put into your data structure.

Also, Java is better for this project than C, but
that is just my opinion.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse XML For Values

Hi All, I want to parse XML to extract values of the tags to do further processing. The XML looks like <?xml version="1.0" encoding="ISO-8859-1"?> <allinput> <input A="2389906" B="install"> <C>111</C> <D>222</D> <E>333</E> <F></F> <G>444</G> <H></H> <I></I> <J></J> <K>C,D,E,G</K>... (6 Replies)
Discussion started by: rahulmittal87
6 Replies

2. Shell Programming and Scripting

Parse xml file

I am trying to create a shell script that will parse an xml file (file attached). awk '/Id v=/ { print }' Test.xml | sed 's!<Id v=\"\(.*\)\"/>!\1!' > output.txt An output.txt file is created but it is empty. It should contain the value 222159 in it. Thanks. (7 Replies)
Discussion started by: cmccabe
7 Replies

3. Shell Programming and Scripting

Parse XML using xmllint

Hi All, Need help to parse the xml file in shell script using xmllint. Below is the sample xml file. <CARS> <AUDI> <Speed="45"/> <speed="55"/> <speed="75"/> <speed="95"/> </AUDI> <BMW> <Speed="30"/> <speed="75"/> <speed="120"/> <speed="135"/> </BMW>... (6 Replies)
Discussion started by: prasanna2166
6 Replies

4. Shell Programming and Scripting

Parse XML File.

HI Guys I have Below XML File : <xn:SubNetwork id="XYZ"> <xn:SubNetwork id="C01"> <xn:MeContext id="CO1"> <xn:ManagedElement id="1"> <un:RncFunction id="1"> <un:UtranCell id="NY431"> ... (2 Replies)
Discussion started by: pareshkp
2 Replies

5. UNIX for Dummies Questions & Answers

Parse xml file

HI Guys, Input .XML <xn:MeContext id="L0307"> <xn:ManagedElement id="1"> <xn:VsDataContainer id="1"> <xn:attributes> <xn:vsDataType>vsDataENodeBFunction</xn:vsDataType> ... (3 Replies)
Discussion started by: pareshkp
3 Replies

6. Shell Programming and Scripting

Parse XML line

Hi I am having an xml file with lines like these <d name="T2tt_350_100" title="T2tt_012j_350_100_428p4_pPF_PU" add="1" color="4" ls="1" lw="2" normf="1" xsection="0.070152" EqLumi="94651.6"... (2 Replies)
Discussion started by: Alkass
2 Replies

7. Shell Programming and Scripting

Parse XML

Hi all! I'm looking to write a quick script and in it I need to request an XML file from a service running on localhost and parse that XML file and output it. I'm looking to do it in bash although it doesn't really matter what shell it is in. The XML file returned would look like this: ... (3 Replies)
Discussion started by: mtehonica
3 Replies

8. Shell Programming and Scripting

Parse an XML task list to create each task.xml file

I have an task definition listing xml file that contains a list of tasks such as <TASKLIST <TASK definition="Completion date" id="Taskname1" Some other <CODE name="Code12" <Parameter pname="Dog" input="5.6" units="feet" etc /Parameter> <Parameter... (3 Replies)
Discussion started by: MissI
3 Replies

9. Shell Programming and Scripting

How can I parse xml file?

How can I parse file containing xml ? I am sure that its best to use perl - but my perl is not very good - can someone help? Example below contents of file containing the xml - I basically want to parse the file and have each field contained in a variable.. ie. I want to store the account... (14 Replies)
Discussion started by: frustrated1
14 Replies

10. Shell Programming and Scripting

How to parse a XML file using PERL and XML::DOm

I need to know the way. I have got parsing down some nodes. But I was unable to get the child node perfectly. If you have code please send it. It will be very useful for me. (0 Replies)
Discussion started by: girigopal
0 Replies
Login or Register to Ask a Question