t-min
asked on
XPathExpression to select nodes with values
I need an XPathExpression to select nodes containing values. So in the sample XML below, the XPathExpression should return the nodes "fred" and "george", but should not return the node "foo" .
I was thinking it would look something like
XPathExpression sitemapExp = XPathExpression.Compile("/ /MyXML/MyI tems/[exis ts(myValue )]");
Any ideas appreciated
I was thinking it would look something like
XPathExpression sitemapExp = XPathExpression.Compile("/
Any ideas appreciated
<MyXML xmlns="">
<MyItems>
<item id="foo"><![CDATA[Foo]]></item>
<item id="fred" myValue="aValue"><![CDATA[fred]]></item>
<item id="george" myValue="aValue"><![CDATA[george]]></item>
</sections>
</MyXML>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No I don't want to select the myValue nodes.
What I need is an XPathExpression as I am using it with XSL. The item nodes are needed by the XSL. I need an expression that will select all item nodes where myValue is not null.
In my question I stated that I wanted to return the nodes "fred" and "george" from my sample XML. It might have been clearer if I had said the item nodes with the ids "fred" and "george". I am interested in the item nodes that have something for myValue.
Does this help explain it more?
What I need is an XPathExpression as I am using it with XSL. The item nodes are needed by the XSL. I need an expression that will select all item nodes where myValue is not null.
In my question I stated that I wanted to return the nodes "fred" and "george" from my sample XML. It might have been clearer if I had said the item nodes with the ids "fred" and "george". I am interested in the item nodes that have something for myValue.
Does this help explain it more?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your ideas. I have found a solution based on the above suggetion..
XPathExpression sitemapExp = XPathExpression.Compile("/ /MyItems/i tem[@myVal ue]");
XPathExpression sitemapExp = XPathExpression.Compile("/
ASKER
Thanks for your help
ASKER
myValue="left"myValue="lef
All these nodes have values which is part of my requirements, but it is the item nodes that I want returned.