ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
1. student name
x
Address
xyz
sports
Yes
drawing
No
singing Na
2.student name
y
Address
zxy
sports
Yes
drawing
No
singing Na
3.student name
z
Address
yzx
sports
No
drawing
Yes
singing
yes
What i will suggest you is if you have access to perl use perl to parse this XML. With shell script you need to do a good amount a calculation, almost a parser in shell script
I am running perl(5.8 version) on suse linux 10 with XML-Simple-2.18, when i run sample code i am getting error as:
not well-formed (invalid token) at line 2, column 25, byte 34 at /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/XML/Parser.pm line 187
code:
#!/usr/bin/perl
use XML::Simple;
$xml = new XML::Simple;
$data = $xml->XMLin("data.xml");
use Data:umper;
print Dumper($data);
Seems like your XML is not valid try running xmllint on it. In case you do not have xmllint try out with simple XML. This seems a problem with the XML file.
I need to work on multilevel xml parsing stuff, do you have any source/links where i can get some inputs on complex parsing, right now i am using XML::LibXML module.
You are parsing XML, hence you are reading XML not writing, what i will suugest you is to stick to XML::Simple it is far easier wrapper thats gives you a perfect data structure from the XML
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.