How to parse XML in Bash?

This is really just an explaination of Yuzem’s answer, but I didn’t feel like this much editing should be done to someone else, and comments don’t allow formatting, so… Let’s call that “read_dom” instead of “rdom”, space it out a bit and use longer variables: Okay so it defines a function called read_dom. The first line makes … Read more

Getting attribute using XPath

How could I get the value of lang (where lang=eng in book title), for the first element? Use: This means: Select the lang attribute of the title element that is a child of the first book child of the top element of the XML document. To get just the string value of this attribute use the standard XPath function string():

XSLT string replace

replace isn’t available for XSLT 1.0. Codesling has a template for string-replace you can use as a substitute for the function: invoked as: On the other hand, if you literally only need to replace one character with another, you can call translate which has a similar signature. Something like this should work fine: Also, note, in this example, I changed … Read more

Is there a way to get element by XPath using JavaScript in Selenium WebDriver?

You can use document.evaluate: Evaluates an XPath expression string and returns a result of the specified type if possible. It is w3-standardized and whole documented: https://developer.mozilla.org/en-US/docs/Web/API/Document.evaluate Expand snippet There’s also a great introduction on mozilla developer network: https://developer.mozilla.org/en-US/docs/Introduction_to_using_XPath_in_JavaScript#document.evaluate Alternative version, using XPathEvaluator: Show code snippet

XPath OR operator for different nodes

All title nodes with zipcode or book node as parent: Version 1: Version 2: Version 3: (results are sorted based on source data rather than the order of book then zipcode) or – used within true/false – a Boolean operator in xpath | – a Union operator in xpath that appends the query to the … Read more

Converting JSON to XML in Java

Use the (excellent) JSON-Java library from json.org then toString can take a second argument to provide the name of the XML root node. This library is also able to convert XML to JSON using XML.toJSONObject(java.lang.String string) Check the Javadoc Link to the the github repository POM original post updated with new links

XPath: Get parent node from child node

Use the parent axes with the parent node’s name. This XPath will only select the parent node if it is a store. But you can also use one of these These xpaths will select any parent node. So if the document changes you will always select a node, even if it is not the node you expect. EDIT What … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)