D
D
Dmitry Kuzmin2015-05-15 07:15:59
linux
Dmitry Kuzmin, 2015-05-15 07:15:59

What is the best way to parse xml in Linux?

There is an XML of the form:

<all>
<config_ftp><hostName>host1</hostName><collector_name>collectors1</collector_name><input_ClassName>FTPSource</input_ClassName><input_policyClassName>Policy</input_policyClassName><input_FileListParser>FTPFileListParser</input_FileListParser><input_Handler>true</input_CleanupHandler><input_UserName>name1</input_UserName><input_PassWord>pass1</input_PassWord><input_FTPServer>server.com</input_FTPServer><input_policySrcDir>/</input_policySrcDir><input_policyFilePattern>SPS.*</input_policyFilePattern></config_ftp>
</all>

I'm trying to get the value of the node using xmllint , for example host1
There are no other tools for parsing xml, except for the standard sets of course.
So far it doesn't work.
Can you suggest more ways to parse xml in the shell? Can with examples if it is not difficult.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergei Borisov, 2015-05-15
@risik

You need xpath. xmllint as I remember it is able.
See for example stackoverflow.com/questions/15461737/how-to-execut...

A
Alexey Sharapov, 2016-03-24
@SicYar

pep8.ru/doc/dive-into-python-3/14.html is also good for this question

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question