XPath contains(text(),’some string’) doesn’t work when used with node with more than one Text subnode

The <Comment> tag contains two text nodes and two <br> nodes as children. Your xpath expression was //*[contains(text(),’ABC’)] To break this down, * is a selector that matches any element (i.e. tag) — it returns a node-set. The [] are a conditional that operates on each individual node in that node set. It matches if … Read more

How to parse XML using vba

Thanks for the pointers. I don’t know, whether this is the best approach to the problem or not, but here is how I got it to work. I referenced the Microsoft XML, v2.6 dll in my VBA, and then the following code snippet, gives me the required values Dim objXML As MSXML2.DOMDocument Set objXML = … Read more

XML to CSV Using XSLT

Here is a version with configurable parameters that you can set programmatically: <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output method=”text” encoding=”utf-8″ /> <xsl:param name=”delim” select=”‘,'” /> <xsl:param name=”quote” select=”‘&quot;'” /> <xsl:param name=”break” select=”‘&#xA;'” /> <xsl:template match=”https://stackoverflow.com/”> <xsl:apply-templates select=”projects/project” /> </xsl:template> <xsl:template match=”project”> <xsl:apply-templates /> <xsl:if test=”following-sibling::*”> <xsl:value-of select=”$break” /> </xsl:if> </xsl:template> <xsl:template match=”*”> <!– remove normalize-space() if you … Read more

What is the difference between .// and //* in XPath?

There are several distinct, key XPath concepts in play here… Absolute vs relative XPaths (/ vs .) / introduces an absolute location path, starting at the root of the document. . introduces a relative location path, starting at the context node. Named element vs any element (ename vs *) /ename selects an ename root element … Read more

Declaring a custom android UI element using XML

The Android Developer Guide has a section called Building Custom Components. Unfortunately, the discussion of XML attributes only covers declaring the control inside the layout file and not actually handling the values inside the class initialisation. The steps are as follows: 1. Declare attributes in values\attrs.xml <?xml version=”1.0″ encoding=”utf-8″?> <resources> <declare-styleable name=”MyCustomView”> <attr name=”android:text”/> <attr … Read more

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… rdom () { local IFS=\> ; read -d \< E C ;} Let’s call that “read_dom” instead of “rdom”, space it out a bit and use … Read more

What are invalid characters in XML

OK, let’s separate the question of the characters that: aren’t valid at all in any XML document. need to be escaped. The answer provided by @dolmen in “https://stackoverflow.com/questions/730133/invalid-characters-in-xml/5110103#5110103” is still valid but needs to be updated with the XML 1.1 specification. 1. Invalid characters The characters described here are all the characters that are allowed … Read more

XML attribute vs XML element

I use this rule of thumb: An Attribute is something that is self-contained, i.e., a color, an ID, a name. An Element is something that does or could have attributes of its own or contain other elements. So yours is close. I would have done something like: EDIT: Updated the original example based on feedback … Read more

What does “xmlns” in XML mean?

It means XML namespace. Basically, every element (or attribute) in XML belongs to a namespace, a way of “qualifying” the name of the element. Imagine you and I both invent our own XML. You invent XML to describe people, I invent mine to describe cities. Both of us include an element called name. Yours refers … Read more