LostProgrammer Posted May 4, 2006 Posted May 4, 2006 I want to select a node set base on the attribute value of a sibling node. I have a nodes <Table Name='Customers> <Field Name='CustomerId'/> <Field Name='AccountNumber'/> </Table> <ExtendedDataType> <Table Name='Customers'/> <Field Name='CustomerId'/> </ExtendedDataType> This query returns all of the Property nodes from the Customers table: /xs:Tables/xs:Table[attribute::Name=Customers]/xs:Propertys/xs:Property I want to replace 'Customers' with parent::Table[attribute::Name] resulting in something like /xs:Tables/xs:Table[attribute::Name=parent::Table[attribute::Name]/xs:Propertys/xs:Property so that I can filter the choices for Field of ExtendedDataType by using the Table Name that has already been selected. can this be done? do i need a variable or something? Thanks for the help, lp Quote
LostProgrammer Posted May 4, 2006 Author Posted May 4, 2006 (edited) ...predicate evaluation if n is the current node: This returns a nodelist with the correct nodes n.SelectNodes("/xs:ObjectTree/xs:DataDictionary/xs:Tables/xs:Table[attribute::Name='Customers']/xs:Propertys/xs:Property", nsmgr) ...And this prints 'Customers' Dim child As XmlNode child = n.SelectSingleNode("parent::node()/xs:Table", nsmgr) MsgBox(child .Attributes("Name").Value) when i replace 'Customers' with "parent::node()/xs:Table/@Name" giving n.SelectNodes("/xs:ObjectTree/xs:DataDictionary/xs:Tables/xs:Table[attribute::Name=parent::node()/xs:Table/@Name]/xs:Propertys/xs:Property", nsmgr) I get a list of all Property Nodes from all Table/Propertys not a filtered list. Shouldn't 'parent::node()/xs:Table/@Name' evaluate to 'Customers' in the expression? thanks, lp Edited May 6, 2006 by PlausiblyDamp Quote
LostProgrammer Posted May 4, 2006 Author Posted May 4, 2006 (edited) same problem, different issue so here's what i left with xs:ObjectTree/xs:DataDictionary/xs:Tables/xs:Table[attribute::Name=parent::node()/xs:Table/@Name]/xs:Propertys/xs:Property" the expression is evaluating correctly, however not like i initially thought. it seems that the reference to parent::node() is the parent of the current Table node, not the parent of the the original context. I can only assume that the xs:ObjectTree/xs:DataDictionary/xs:Tables/xs:Table changes the context of the expression. So the question becomes, how do i reference the original context node after some traversal of the tree(objecttree/datadictionary/tables/table)? Edited May 6, 2006 by PlausiblyDamp Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.