LinuxQuestions.org
Visit Jeremy's Blog.
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

Reply
 
Search this Thread
Old 11-27-2008, 10:01 AM   #1
QuietLeni
LQ Newbie
 
Registered: Sep 2008
Location: South East England
Distribution: Red Hat
Posts: 11

Rep: Reputation: 0
Question Is there an XML-manipulation tool for Linux?


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
 
Old 11-27-2008, 11:24 AM   #2
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 276
Blog Entries: 2

Rep: Reputation: 44
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.
 
Old 11-27-2008, 05:54 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,289

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
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
 
Old 11-28-2008, 12:45 AM   #4
burschik
Member
 
Registered: Jul 2008
Posts: 159

Rep: Reputation: 31
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.
 
Old 11-30-2008, 04:11 AM   #5
Thor_2.0
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,217
Blog Entries: 23

Rep: Reputation: 279Reputation: 279Reputation: 279
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
 
  


Reply

Tags
shell, xml


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 12:50 PM
LXer: Subtitle manipulation tools for Linux LXer Syndicated Linux News 0 02-07-2008 07:30 PM
Linux Text Manipulation Question resolute155 Programming 2 01-02-2007 05:48 PM
Linux folder and file manipulation help resolute155 Programming 4 12-20-2006 10:32 AM
C File Manipulation in Linux drigz Programming 5 10-01-2004 07:28 AM


All times are GMT -5. The time now is 12:08 PM.

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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration