I'd like to add an element to a xml document and I'd like to pass as a parameter the path to the element.
sample.xml file:
<?xml version="1.0"?>
<stuff>
<element1>
<foo>2</foo>
<bar/>
</element1>
<element2>
<subelement/>
<bar/>
</element2>
<element1>
<foo/>
<bar/>
</element1>
</stuff>
Using:
xalan.exe -p my...
I have XML something like this:
<?xml version="1.0"?>
<a xmlns="http://mynamespace">
<b>
<c val="test" />
<b>
</a>
And I am trying to find the value of the 'val' attribute on the 'c' tag with something like this:
XmlDocument doc = new XmlDocument();
doc.Load("myxml.xml");
nsMgr = new XmlNamespaceManager(doc.NameTable);
ns...
Here is a sample xml file that I am trying to pull data from:
<rss>
<channel>
<item>
<title>First Title</title>
<description>description text</description>
<component>Distribution - Maintain</component>
<timeoriginalestimate seconds="3600">1 hour</timeoriginalestimate>
<timespent seconds="1860">31 minutes</timespent>
...
Consider the following html fragment:
<table>
<tr>
<td>One</td><td>1</td>
<td>Two</td><td>2</td>
</tr>
</table>
I want to use xpath to find the second td ("1" or "2") based on the value of the first td ("One" or "Two). Something like:
/table/tr/td[text() = 'One']/../td
or
/table/tr/td[text(), 'One']/../td
Any ideas?
...
Sorry in advance if I don't explain this clearly. I will try my best to clarify what I am trying to do. Without further ado...Suppose you have a series of numbers on a page (separated by only a space) where brackets indicate the current page you are on.
It looks like this on the page:
[1] 2 3
The HTML looks like this:
<tr>
<td>
[<a...
I have a catalog processor I've built that updates itself by evaluating an xml based manifest file for the current state and comparing it to the local manifest.xml.
I currently process every node to look for a difference in some of the attributes to determine if an update needs to occur. I loop through every node in the tree.
I was won...
Is it possible to create an XPath expression that matches all child nodes that are not of a certain name? E.g.
<a>
<b />
<c />
<d />
<e />
<f />
<g />
</a>
How would I select all children of the 'a' node that are not a 'b' node?
...
Hi I am usually programming in c++ so XML/XSL/XPATH is not my strong side, but I need to do a transformation and I cannot seem to find a good way of doing it.
We have an xml file that is formatted like this:
<outer>
<element/>
<other_element/>
<message pri="info">
[[!CDATA Error: something is not working]]
</message>
<me...
I'm trying to create a function in Groovy that does the following:
Accepts 2 parameters at runtime (a string of XML, and an xpath query)
Returns the result as text
This is probably quite straightforward but for two obstacles:
This has to be done in groovy
I know next to nothing nothing about groovy or Java…
This is as far as I've...
I'm trying to select nodes from an rss feed. It works fine for Twitter, but I can't do it on Youtube.
string youtube = "http://gdata.youtube.com/feeds/api/users/CTVOlympics/uploads";
string twitter = "http://twitter.com/statuses/user_timeline/ctvolympics.rss";
//this populates the XmlNodeList object
Xml...
Hi,
Just a quick question as to the difference between xpath's 'not' and '!=' in the following content.
Taking the XML:
<years>
<year value="2010"></year>
<year value="2010"></year>
<year value="2010"></year>
<year value="2009"></year>
</years>
I want to select unique years. I have struggled for a while to achieve this, but ...
I'm writing javascript code to traverse and manipulate deeply nested XML documents. With modern browsers, is there still a need for crossbrowser libraries like:
sarissa
ajaxslt
As far as I know, without using one of these there won't be any XPath in IE with ActiveX disabled. And a simple wrapper is needed for both XSLT and XPath to d...
So,
I have an XSLT template which expects a node set as a parameter and uses this as display text. However, sometimes this node is empty in the XML and I want to pass default display text instead of the display text not showing up instead:
Works:
<xsl:call-template name="myTemplate">
<xsl:with-param name="parm1" select="//element"...
I'm trying to sum up a set of values in an XML using XSLT and XPath function fn:sum. This works fine as long as the values are non-null, however this is not the case. To illustrate my problem I've made an example:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
...
I'm using nokogiri to select the 'keywords' attribute like this:
puts page.parser.xpath("//meta[@name='keywords']").to_html
One of the pages I'm working with has the keywords label with a capital "K" which has motivated me to make the query case insensitive.
<meta name="keywords"> AND <meta name="Keywords">
So, my question is: W...
Hi all,
I am not sure I am going to be able to explain this one right as it may be difficult for me to explain, but I am going to try.
I have a web form which it publish the data to a XML file, then it shows the data in another web page.
Everything works fine, but when the user types a double quote character, at the time the web page ...
Hi,
I'm trying to select elements (a) with XPath 1.0 (or possibly could be with Regex) that are following siblings of particular element (b) but only preceed another b element.
<img><b>First</b><br>
<img> <a href="/first-href">First Href</a> - 19:30<br>
<img><b>Second</b><br>
<img> <a href=...
I have some XML like this:
<topics>
<topic id="50"/>
<topic id="51"/>
<topic id="52"/>
</topics>
<discussions>
<discussion type="foo">talked about T50 as Discussion 1000</discussion>
<discussion type="bar">Food is yummy!</discussion>
<discussion type="foo">talked about T52 as Discussion 1050</discussion>
</discussions>
Gi...
With XSLT, how can I change the following:
<root>
<element id="1" State="Texas" County="Dallas" Population="2412827" />
<element id="2" State="Texas" County="Harris" Population="3984349" />
<element id="3" state="Georgia" County="Fulton" Population="1014932" />
<element id="4" state="Georgia" County="Richmond" Population="212775...
I've seen a few questions on this topic already but I'm looking for some insight on the performance differences between these two techniques.
For example, lets say I am recording a log of events which will come into the system with a dictionary set of key/value pairs for the specific event. I will record an entry in an Events table with...