thanks Martin
I tried to add the "@" in front of the attribute keywordand I got the
following error
System.Xml.XPath.XPathException
Message:
The expression passed to this method should result in a NodeSet.
Stack Track:
at System.Xml.XPath.XPathParser.ParseNodeTest(AstNode qyInput, AxisType
axisType, XPathNodeType nodeType)
at System.Xml.XPath.XPathParser.ParseStep(AstNode qyInput)
at System.Xml.XPath.XPathParser.ParseRelativeLocation Path(AstNode
qyInput)
at System.Xml.XPath.XPathParser.ParseLocationPath(Ast Node qyInput)
at System.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput)
at System.Xml.XPath.XPathParser.ParseUnionExpr(AstNod e qyInput)
at System.Xml.XPath.XPathParser.ParseUnaryExpr(AstNod e qyInput)
at System.Xml.XPath.XPathParser.ParseMultiplicativeEx pr(AstNode qyInput)
at System.Xml.XPath.XPathParser.ParseAdditiveExpr(Ast Node qyInput)
at System.Xml.XPath.XPathParser.ParseRelationalExpr(A stNode qyInput)
at System.Xml.XPath.XPathParser.ParseEqualityExpr(Ast Node qyInput)
at System.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput)
at System.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput)
at System.Xml.XPath.XPathParser.ParseExpresion(AstNod e qyInput)
at System.Xml.XPath.XPathParser.ParsePredicate(AstNod e qyInput)
at System.Xml.XPath.XPathParser.ParseStep(AstNode qyInput)
at System.Xml.XPath.XPathParser.ParseRelativeLocation Path(AstNode
qyInput)
at System.Xml.XPath.XPathParser.ParseLocationPath(Ast Node qyInput)
at System.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput)
at System.Xml.XPath.XPathParser.ParseUnionExpr(AstNod e qyInput)
at System.Xml.XPath.XPathParser.ParseUnaryExpr(AstNod e qyInput)
at System.Xml.XPath.XPathParser.ParseMultiplicativeEx pr(AstNode qyInput)
at System.Xml.XPath.XPathParser.ParseAdditiveExpr(Ast Node qyInput)
at System.Xml.XPath.XPathParser.ParseRelationalExpr(A stNode qyInput)
at System.Xml.XPath.XPathParser.ParseEqualityExpr(Ast Node qyInput)
at System.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput)
at System.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput)
at System.Xml.XPath.XPathParser.ParseExpresion(AstNod e qyInput)
at System.Xml.XPath.XPathParser.ParseXPathExpresion(S tring
xpathExpresion)
at System.Xml.XPath.QueryBuilder.Build(String query, Boolean allowVar,
Boolean allowKey)
at System.Xml.XPath.QueryBuilder.Build(String query, Boolean& hasPrefix)
at System.Xml.XPath.XPathNavigator.Compile(String xpath)
at System.Xml.XPath.XPathNavigator.Select(String xpath)
at System.Xml.XmlNode.SelectNodes(String xpath)
at System.Xml.XmlNode.SelectSingleNode(String xpath)
I am sure the node name and the attribute is correct (in fact I think the
specified node is not found it will return null instead of giving an
exception rite?)
Any clue?
thanks
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:ed****************@TK2MSFTNGP09.phx.gbl...
Gnic wrote:
so my question is, given a node name and attributes (name and value), if
any, how can I find a node in the xml doc from the root element (any
method is ok, not necessary using xpath)?
Then use an XPath expression alike
//aaa[@attr = 'y']
that selects aaa elements at all levels without the need to specify all
ancestor names.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/