LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Is there an XML-manipulation tool for Linux? (https://www.linuxquestions.org/questions/programming-9/is-there-an-xml-manipulation-tool-for-linux-686649/)

QuietLeni 11-27-2008 10:01 AM

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

raconteur 11-27-2008 11:24 AM

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.

chrism01 11-27-2008 05:54 PM

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

burschik 11-28-2008 12:45 AM

Quote:

Originally Posted by QuietLeni (Post 3356797)
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.

ButterflyMelissa 11-30-2008 04:11 AM

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


All times are GMT -5. The time now is 12:45 AM.