on 11-21-2006 12:49 PM
Hi!
I have Node strucrure like this in my context..
Node (0..n)(singleton="true")
Node1 (0..n)(singleton="true")
Node11 (0..n)(singleton="true")
atrr1
attr2
Can you tell me that how can I access Node11 and its attributes?
Iam having n number of Node1's under each Node and again n number of Node11's under each Node1. I need to access attributes of each Node11. How can i do that??
Thanks,
Archana
Hi Archana,
As u described ur scenario, there are multiple instances of Node1 exist for Node
and Node11 for Node1.So u have to set "singleton" property of child nodes to false.
Otherwise the elements of the relevant node are instantiated for only one element of the parent node.
for(int i=0;i<wdContext.nodeNode().size();i++)
{
wdContext.nodeNode().setLeadSelection(i);
for(int j=0;j<wdContext.nodeNode1().size();j++)
{
wdContext.nodeNode1().setLeadSelection(j);
for(int k=0;k<wdContext.nodeNode11().size();k++)
{
wdContext.nodeNode11().setLeadSelection(k);
wdContext.currentNode11Element.getAttributeValue("attrName");
}
}
}
Hope it helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Archana,
Since its singleton property has been set to true u dont need to iterate on parent node.U can directly iterate child node
if(wdContext.nodeNode11()!=null)
{
for(int k=0;k<wdContext.nodeNode11().size();k++)
{
wdContext.nodeNode11().setLeadSelection(k);
wdContext.currentNode11Element.getAttributeValue("attrName");
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this,
String att1 = null, att2 = null;
for(int i =0; i<wdContext.nodeNode().size; i++){
for(int j = 0; j<wdContext.nodeNode().nodeNode1().size; j++){
for(int k = 0; k<wdContext.nodeNode().nodeNode11().size; k++){
att1 = wdContext.nodeNode().nodeNode1().nodeNode11().getNode11ElementAt(k).getAtt1();
att2 = wdContext.nodeNode().nodeNode1().nodeNode11().getNode11ElementAt(k).getAtt2();
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The proposed cardinality for parent node should be 1:n & for Child nodes it should be 0:1.
u can access the child node attributes like this.
String one =WdContext.current<childNode>Element()..getAttr1();
String two =WdContext.current<childNode>Element()..getAttr2();
Thanks,
Lohi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can directly access a child node like node11 from the context using wdContext.currentnode11Element().getAttr1() provided node11 has atleast 1 line.All the parent contexts must be initialised as well(here you have to do explicity by addelement() as you have all cardinalities as 0..n)
To access each element , you can put it in a for loop.
Regards,
LM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
wdContext.currentNodeElement().currentNode1Element().currentNode11Element().getAtrr1();
You can surf the context:
wdContext.nodeNode().movefirst();
do{
wdContext.currentNodeElement().nodeNode1().movefirst();
do{
wdContext.currentNodeElement().currentNode1Element().nodeNode11().movefirst();
do{
wdContext.currentNodeElement().currentNode1Element().currentNode11Element().getAtrr1();
} while ( wdContext.currentNodeElement().currentNode1Element().nodeNode11() );
} while ( wdContext.currentNodeElement().nodeNode1().moveNext() );
} while ( wdContext.nodeNode().moveNext() );
Message was edited by:
Roberto Tagliento
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Archana,
Select the cardinality as (1..1) for the root node and for the remaing nodes keep the same(0..n). I mean if your node11 is in node1 and node1 is in node you have to make the cardinality (1..1) for node, and for the remaing node node1 and for node11 keep the same cardinality (0..n).
Regards
Suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.