Navigating XML nodes in VBScript, for a Dummy

Here is a small example: Suppose you have a file called C:\Temp\Test.xml with this contents: <?xml version=”1.0″?> <root> <property name=”alpha” value=”1″/> <property name=”beta” value=”2″/> <property name=”gamma” value=”3″/> </root> Then you can use this VBScript: Set objDoc = CreateObject(“MSXML.DOMDocument”) objDoc.Load “C:\Temp\Test.xml” ‘ Iterate over all elements contained in the <root> element: Set objRoot = objDoc.documentElement s … Read more

What is the XPath to select a range of nodes?

Use: /*/bar[position() >= 100 and not(position() > 200)] Do note: Exactly the bar elements at position 100 to 200 (inclusive) are selected. The evaluation of this XPath expressions can be many times faster than an expression using the // abbreviation, because the latter causes a complete scan of the tree whose root is the context … Read more

In XSLT how do I increment a global variable from a different scope?

Others have already explained how variables are immutable–that there are no assignment statements in XSLT (as with purely functional programming languages in general). I have an alternative to the solutions that have been proposed so far. It avoids parameter passing (which is verbose and ugly in XSLT–even I’ll admit that). In XPath, you can simply … Read more

Extract XML Value in bash script [duplicate]

As Charles Duffey has stated, XML parsers are best parsed with a proper XML parsing tools. For one time job the following should work. grep -oPm1 “(?<=<title>)[^<]+” Test: $ echo “$data” <item> <title>15:54:57 – George:</title> <description>Diane DeConn? You saw Diane DeConn!</description> </item> <item> <title>15:55:17 – Jerry:</title> <description>Something huh?</description> $ title=$(grep -oPm1 “(?<=<title>)[^<]+” <<< “$data”) $ … Read more

R: convert XML data to data frame

It may not be as verbose as the XML package but xml2 doesn’t have the memory leaks and is laser-focused on data extraction. I use trimws which is a really recent addition to R core. library(xml2) pg <- read_xml(“http://www.ggobi.org/book/data/olive.xml”) # get all the <record>s recs <- xml_find_all(pg, “//record”) # extract and clean all the columns … Read more

Add CDATA to an xml file

You either need to do this: <xsl:template match=”teaserText_fr”> <xsl:copy> <xsl:text disable-output-escaping=”yes”>&lt;![CDATA[</xsl:text> <xsl:copy-of select=”*”/> <xsl:text disable-output-escaping=”yes”>]]&gt;</xsl:text> </xsl:copy> </xsl:template> Or this: <xsl:template match=”teaserText_fr”> <teaserText_fr> <xsl:text disable-output-escaping=”yes”>&lt;![CDATA[</xsl:text> <xsl:copy-of select=”*”/> <xsl:text disable-output-escaping=”yes”>]]&gt;</xsl:text> </teaserText_fr> </xsl:template> (I recommend the first approach) and you should be all set. To give the same treatment to any element whose name starts with “teaserText_”: <xsl:template … Read more

where to find xsd.exe in visual studio 2013 on windows 8

Once you have the SDK installed * (either Manually, or with Visual Studio), you’ll find it in the following directories: SDK 8 and later There is an an additional FX version subdirectory: %programfiles(x86)%\Microsoft SDKs\Windows\{ver}\bin\{FXVer} Tools Where {ver} is the SDK version (e.g. v8.1A) and {FXVer} is the applicable .Net Framework version, e.g. NETFX 4.0v e.g. … Read more