5 ms·
I do a great deal of work in DevOps and I have a text file full of scripts which come handy to do work like this during production issues. Nearly every sysadmi
by kamaal 13y ago
I do a great deal of work in DevOps and I have a text file full of scripts which come handy to do work like this during production issues.
Nearly every sysadmin/firefigher I know has command line perl/awk/sed magic text files full of this.
Having said that I would appreciate if something like this was available for XMLs. Having to deal with SQL designs force fully shoe horned into NoSQL databases so often these days. I frequently run into situations where I have to query data from XML dumps. Most of the time, I have to invent a Perl one liner that essentially does the job of a select query.
- amouat 13y agoWell there is XSL and XQL (XML Query Language). There doesn't seem to be many XQL implementations, but this looks interesting: http://www.cs.york.ac.uk/fp/Xtract/ http://www.cs.york.ac.uk/fp/Xtract/. Also check xmllint and xmlstar.
- rcfox 13y agoI've done this a few times with XPath from an ipython shell, using the lxml module to parse the XML and handle the XPath queries. 30-second XPath pitch: //foo/bar This gets the 'bar' children from every 'foo', regardless of where it occurs in the hierarchy. //baz[@name='Alice'] Gets everything like: <baz name="Alice"> There's lots of more complicated things you can do, but these are the most frequent types of things I've had to do.
- barrkel 13y agoI have a command-line thing put together with HtmlAgilityPack that represents HTML in an XPath-navigable document. It lets me apply the same XPath queries to HTML, for screen scraping.
- rcfox 13y agoOh, that reminds me: You can use XPath in Chrome with $x(). To get all of the links on the current page, open up the console and type: $x('//a')
- samsquire 13y agoI've found xmlstarlet is wonderful if you are want to use XPath on the terminal. Great with curl + XML APIs like Jenkins. xml sel --template --value-of "//foo/bar" \ --template --value-of "//baz[@name='Alice']" << EOF <foo> <bar>hello</bar> <baz name="Alice"> world</baz> </foo> EOF http://xmlstar.sourceforge.net/docs.php http://xmlstar.sourceforge.net/docs.php It also can edit with XPath which is really handy.
- dinedal 13y agoAuthor here. XML/HTML support, via XPATH selectors, is coming. I would love to be able to pipe the output of curl through this!