For example consider the following xml
<root>
<childNode attribute1="value1">
<grandChildNode attrib1="val1" attrib2="val2">some content1
</grandChildNode>
<grandChildNode attrib1="val1" attrib2="val2">some content2
</grandChildNode>
<grandChildNode attrib1="val1" attrib2="val2">some content3
</grandChild...
In an xpath expression, I understand that I can have variable references of the form
$myVar
I'm using Yahoo! widgets. What are these for? How would I set the value of myVar in the first place? Are these variables from the JavaScript?
...
I'm writing a user-defined function to extract values from an XML column in SQL Server which represents a simple dictionary of string key-value pairs. The only way I've made it work so far seems overly complex. Do you have any simplifying suggestions or tips for the DictValue function below?
IF EXISTS (SELECT * FROM sys.objects WHERE...
What I tried to say in the title is:
Given a bit of XML in which I know a particular element appears only once, is it possible using a single XPath query to select a node-set that contains that element twice?
I understand there's a "union" operator (|) but that's basically a logical-OR, right? In SQL terms I'm looking then for the equ...
I want to be able to grab content from web pages, especially the tags and the content within them. I have tried XQuery and XPath but they don't seem to work for malformed XHTML and REGEX is just a pain.
Is there a better solution. Ideally I would like to be able to ask for all the links and get back an array of URLs, or ask for the text...
Say I have this piece of xml:
<AA>
<BB>foo</BB>
<CC>bar</CC>
<DD>baz</DD>
<EE>bar</EE>
</AA>
How do I select all the child nodes of <AA> that have `bar' as its contents? In the example above, I'd want to select <CC> and <EE>. I'm thinking the solution is something like:
<xsl:template match="AA">
<xsl:for-each select="???">
</xsl:fo...
Given a piece of Xml Like the one below. How would I write an XPATH Query to get the value of the 'leaf2' child where the 'key' value has a particular values (say 2)
I'm working in C# .NET. At the moment I'm just looking at getting the Xpath for key using SelectNodes , finding the right value then navigating back up to leaf2.
<root>
...
given this simplified data format:
<a>
<b>
<c>C1</c>
<d>D1</d>
<e>E1</e>
<f>don't select this one</f>
</b>
<b>
<c>C2</c>
<d>D2</d>
<e>E1</e>
<g>don't select me</g>
</b>
<c>not this one</c>
<d>nor this one</d>
<e>definitely not this one</e>
</a>
...
I have a repeating xml tree like this -
<xml>
<head>this is a sample xml file</head>
<item><color>yellow</color><color>red</color></item>
<item><color>blue</color></item>
<item><color>grey</color><color>red</color><color>blue</color></item>
</xml>
As you can see, each item can have a varying number of color tags.
I wish to ge...
All of the examples I can find online about this involve simply adding content to an XML file at the document root, but I really need to do it deeper than that.
My XML file is simple, I have:
<?xml v1 etc>
<channel>
<screenshots>
<item>
<title>Image Title</title>
<link>www.link.com/image.jpg</link>
</item>
</screenshots>
</channel>...
I'm trying to extract some info from a table based website with hpricot. I get the XPath with FireBug.
/html/body/div/table/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr[3]/td/table[3]/tbody/tr
This doesn't work... Apparently, the FireBug's XPath, is the path of the rendered HTML, and no the actual HTML from the...
Hi,
My question is: using XSLT, how to count the total number of QUOTE tag (please see the sample code below)
The result need to be exported in HTLM, it will display like this: There are total 6 quotes
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="text.xsl" ?>
<quotes>
<quote>Quote 1 </quote>
...
Duplicate of
HOw to make the text repeat only once every for-each?
I have problem with using XPATH to point to some element in XML.
Here is my XML code:
<character>
<name>some name </some name>
</character>
</quote>
<quote>
....
</quote>
</quotes>
and here My XSLT code:
<xsl:for-eac...
I've got a question about loading attribute in XPATH.
I write short XML code to test:
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="testDate.xsl"?>
<element attribute="1/1/2100">
Hung
</element>
My XSL code:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="ht...
I'm trying to get an xpath xpression that will remove my outer tag, but it's removing that, plus the inner tag and printing the element data. How do I get it to print my prompt tags also? Hope someone knows...
My php looks like this:
<?php
#get file
$xml = simplexml_load_file('content.xml') or die ("Unable to load XML string!");
#lo...
I think what I need is CROSS APPLY, but I can't seem to figure out the syntax. I have a set of XML in an MSSQL 2008 database that looks like this:
<Cookie>
<id>Chocolate Chip</id>
<ChocolateChipPeanutButter>
...
</ChocolateChipPeanutButter>
<ChocolateChipPecan>
...
</ChocolateChipPecan>
</Cookie>
<Cookie>
...
$xpath->query('/html[boolean(string(normalize-space(@xml:lang))) = "true"]')
Normally the above query would work but in this case the xhtml attribute xml:lang has colon in it. Replacing it with entity doesn't work either.
Any suggestions?
...
Using a xpath query how do you find if a node (tag) exists at all?
For example if I needed to make sure a website page has the correct basic structure like /html/body and /html/head/title
...
I have an xml column in SQL Server 2005 that is the equivalent of:
<Test foo="bar">
<Otherstuff baz="belch" />
</Test>
I want to be able to get the value of the foo attribute of Test (the root element) as a varchar. My goal would be something along the lines of:
select cast( '<Test foo="bar"><Otherstuff baz="belch" /></Test>' as xm...
I want to write an XPath that can return some link elements on an HTML DOM.
The syntax is wrong, but here is the gist of what I want:
//web:link[@text='Login' THEN_TRY @href='login.php' THEN_TRY @index=0]
THEN_TRY is a made-up operator, because I can't find what operator(s) to use. If many links exist on the page for the given set of...