Quantcast
Channel: How to execute XPath one-liners from shell? - Stack Overflow
Browsing latest articles
Browse All 20 View Live

Answer by Kanagavelu Sugumar for How to execute XPath one-liners from shell?

For github action with ubuntu:To print pom version and updating: - name: "test xmlstarlet" id: xmlstarlet run: | sudo apt-get install xmlstarlet xmlstarlet el pom.xml xmlstarlet sel -t -v...

View Article



Answer by Marinos An for How to execute XPath one-liners from shell?

A solution that works even when namespace declarations exist on top:Most of the commands proposed in the answers do not work out of the box if the xml has a namespace declared on top. Consider...

View Article

Answer by brotatochip for How to execute XPath one-liners from shell?

Sorry to be yet another voice in the fray. I tried all the tools in this thread and found none of them to be satisfactory for my needs, so I wrote my own. You can find it here:...

View Article

Answer by igneus for How to execute XPath one-liners from shell?

Install the BaseX database, then use it's "standalone command-line mode" like this:basex -i - //element@attribute < filename.xmlorbasex -i filename.xml //element@attributeThe query language is...

View Article

Answer by d33tah for How to execute XPath one-liners from shell?

I wasn't happy with Python one-liners for HTML XPath queries, so I wrote my own. Assumes that you installed python-lxml package or ran pip install --user lxml:function htmlxpath() { python -c 'for x in...

View Article


Answer by Andreas Nolda for How to execute XPath one-liners from shell?

My Python script xgrep.py does exactly this. In order to search for all attributes attribute of elements element in files filename.xml ..., you would run it as follows:xgrep.py "//element/@attribute"...

View Article

Answer by diemo for How to execute XPath one-liners from shell?

Here's one xmlstarlet use case to extract data from nested elements elem1, elem2 to one line of text from this type of XML (also showing how to handle namespaces):<?xml version="1.0"...

View Article

Answer by mgrandi for How to execute XPath one-liners from shell?

Since this project is apparently fairly new, check out https://github.com/jeffbr13/xq , seems to be a wrapper around lxml, but that is all you really need (and posted ad hoc solutions using lxml in...

View Article


Answer by ccpizza for How to execute XPath one-liners from shell?

A minimal wrapper for python's lxml module that will print all matching nodes by name (at any level), e.g. mysubnode or an XPath subset e.g. //intermediarynode/subnode. If the expression evaluates to...

View Article


Answer by sideshowbarker for How to execute XPath one-liners from shell?

clacke’s answer is great but I think only works if your source is well-formed XML, not normal HTML.So to do the same for normal Web content—HTML docs that aren’t necessarily well-formed XML:echo...

View Article

Answer by Geoff Nixon for How to execute XPath one-liners from shell?

It bears mentioning that nokogiri itself ships with a command line tool, which should be installed with gem install nokogiri.You might find this blog post useful.

View Article

Answer by pdr for How to execute XPath one-liners from shell?

Similar to Mike's and clacke's answers, here is the python one-liner (using python >= 2.5) to get the build version from a pom.xml file that gets around the fact that pom.xml files don't normally...

View Article

Answer by Mike for How to execute XPath one-liners from shell?

In my search to query maven pom.xml files I ran accross this question. However I had the following limitations: must run cross-platform. must exist on all major linux distributions without any...

View Article


Answer by G. Cito for How to execute XPath one-liners from shell?

In addition to XML::XSH and XML::XSH2 there are some grep-like utilities suck as App::xml_grep2 and XML::Twig (which includes xml_grep rather than xml_grep2). These can be quite useful when working on...

View Article

Answer by clacke for How to execute XPath one-liners from shell?

One package that is very likely to be installed on a system already is python-lxml. If so, this is possible without installing any extra package:python -c "from lxml.etree import parse; from sys import...

View Article


Answer by Michael Kay for How to execute XPath one-liners from shell?

Saxon will do this not only for XPath 2.0, but also for XQuery 1.0 and (in the commercial version) 3.0. It doesn't come as a Linux package, but as a jar file. Syntax (which you can easily wrap in a...

View Article

Answer by BeniBela for How to execute XPath one-liners from shell?

You can also try my Xidel. It is not in a package in the repository, but you can just download it from the webpage (it has no dependencies).It has simple syntax for this task:xidel filename.xml -e...

View Article


Answer by choroba for How to execute XPath one-liners from shell?

You might also be interested in xsh. It features an interactive mode where you can do whatever you like with the document:open 1.xml ;ls //element/@id ;for //p[@class="first"] echo text() ;

View Article

Answer by Gilles Quénot for How to execute XPath one-liners from shell?

You should try these tools :xidel (xidel): xpath3xmlstarlet (xmlstarlet page) : can edit, select, transform... Not installed by default, xpath1xmllint (man xmllint): often installed by default with...

View Article

How to execute XPath one-liners from shell?

Is there a package out there, for Ubuntu and/or CentOS, that has a command-line tool that can execute an XPath one-liner like foo //element@attribute filename.xml or foo //element@attribute <...

View Article
Browsing latest articles
Browse All 20 View Live




Latest Images