LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Tags used in this thread
Popular LQ Tags ,

Reply
 
Thread Tools
Old 11-27-2008, 11:01 AM   #1
QuietLeni
LQ Newbie
 
Registered: Sep 2008
Location: South East England
Distribution: Red Hat
Posts: 6
Thanked: 0
Question Is there an XML-manipulation tool for Linux?


[Log in to get rid of this advertisement]
Dear All,

I have received an XML document that I need to process and then output in a user-readable format. Does anyone know of a Linux XML-manipulation tool that I can use with shell script?

Regards,


QuietLeni
QuietLeni is offline  
Tag This Post ,
Reply With Quote
Old 11-27-2008, 12:24 PM   #2
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 238
Blog Entries: 2
Thanked: 11
Depending on how complex the XML code is, and just how much info you want to extract, there are several options.

The simplest method is, of course, to use a shell regular expression to grab the text between whatever XML tags you wish to display or save, and perhaps parse out and handle or delete any embedded tags in that text. I use that method to convert XML RSS feeds to plain text.

On the other end of the scale, some folks have created bash extensions for the expat XML library, a web search should show you examples. Some of them are overly complex and arcane, in my opinion, but take that with a grain of salt, it is only an opinion.
raconteur is offline     Reply With Quote
Old 11-27-2008, 06:54 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 5.4
Posts: 7,411
Thanked: 324
Perl has several XML modules eg http://search.cpan.org/~mirod/XML-Twig-3.32/Twig.pm, http://search.cpan.org/~grantm/XML-S.../XML/Simple.pm
chrism01 is offline     Reply With Quote
Old 11-28-2008, 01:45 AM   #4
burschik
Member
 
Registered: Jul 2008
Posts: 158
Thanked: 0
Quote:
Originally Posted by QuietLeni View Post
I have received an XML document that I need to process and then output in a user-readable format.
If this means pretty-printing XML, then xmllint might be suitable.
burschik is offline     Reply With Quote
Old 11-30-2008, 05:11 AM   #5
linusr@flanders
Member
 
Registered: Nov 2007
Location: Flanders/belgium
Distribution: Fedora 10 as main OS and CentOS 5.2 as test 'n dev server
Posts: 135
Thanked: 0
Wink

Hi!

If it is well-behaved XML - IE well formed, you should be able to simply open/view it with your webbrowser. Double-click the file, I bet the browser will start up and display the text...
My reasoning? If it is prinable XML, it has to have an accompanying DTD file that dictates how the browser (or indeed any XMLcapable piece of software) has to display the data...

If not, then the XML could "belong" to some receicing software. As with many settings, software saves these a XML, without the DTD, as the data needs no displaying...

Grtz!

Thor
linusr@flanders is offline     Reply With Quote

Reply

Bookmarks


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 On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mal-format xml checking tool ufmale Programming 1 09-05-2008 01:50 PM
LXer: Subtitle manipulation tools for Linux LXer Syndicated Linux News 0 02-07-2008 08:30 PM
Linux Text Manipulation Question resolute155 Programming 2 01-02-2007 06:48 PM
Linux folder and file manipulation help resolute155 Programming 4 12-20-2006 11:32 AM
C File Manipulation in Linux drigz Programming 5 10-01-2004 08:28 AM


All times are GMT -5. The time now is 07:44 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration