Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Like on an XML document 1

Status
Not open for further replies.

LokiDba

Programmer
Dec 13, 2000
63
GB
Hi,

I'm trying to do the equilivant to a Like or Wildcard search ( '*FRED*' to find any node containing FRED ) on the values in the nodes of an XML document. I've looked at XPath and XQuery and don't seem to be able to do this.

Is this the case or is there a way of doing it.

Thanks in advance


Andy
 
Thanks for the response k5tm

The only problem is I need to know the node. Im looking for the node(s) that contains the value. What I'm trying to do is like find in notepad except its ignoring the tags and attributes it only looks at the values once its found the value then I want to know the nodes / attributes.

I'm probably going to have to transverse the tree to find the nodes / attrubutes.

But thanks again for the response

Andy
 
Well, attributes are nodes.

Exactly what do you mean by 'the value' of a node? This could be construed several ways, so you need to be more precise.

As to the issue of needing to know the nodes for which 'the value' qualifies, when used in a context to select (or match) nodes, the XPath expression designates the nodes which qualify using predicates. Predicates act as filters that restrict the nodes that are selected by an XPath expression. You can use XPath (and XSLT) functions inside predicates. Check out my last post in this thread, thread426-1164762, and you will see the following:
Code:
<xsl:apply-templates select="*[local-name() != '']" mode="showme"/>
Perhaps for you this might be something like:
Code:
<xsl:apply-templates select="*[contains(local-name(), 'FRED')]" />
Does this, suitably modified to qualify 'the value of a node', address your requirement?

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top