cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing different child nodes

Former Member
0 Kudos

Hello,

I have a node containing two attributes and another node.

NodeA

Attr1

Attr2

NodeB

Now I have more than one element of NodeA. How do I access the corresponding NodeB of each element?

Thank You,

Motaz

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Dear Krishna,

I solved my problem.

Thank You for trying to help

Regards,

Motaz

Former Member
0 Kudos

Hi All,

Well Marco I saw my where I was going wrong by reading that line of code you posted.

I had been setting the lead selection of NodeB instead of NodeA.

Thank You very much.

And Thank You Saleem for trying to help.

Regards,

Motaz

Former Member
0 Kudos

By default if you create any node under Root node directly the singleton property of the node will be set to true (you can't modif this). You can create a singleton/ non singleton child node under that node.If you create a singleton node as child node:There will be only one instance for that that node at runtime for all the elements of parent node.

Singleton child node

ParentValueNode
-------------ValueAtt1OfParentValueNode
------------->ChildValueNode(singleton=true)
----------------------->ValueAtt1OfChildValueNode

How to populate the elements of this node:


IPrivateTestView.IParentValueNodeElement parentElement=wdContext.createParentValueNodeElement();
parentElement.setValueAtt1OfParentValueNode("ParentValue1");

//Before this line getting executed the parent node should be initialized by adding atleast one element	
IPrivateTestNewView.IChildValueNodeElement childElement=
wdContext.createChildValueNodeElement();
childElement.setValueAtt1OfChildValueNode("ChildValue1");

How to access the elements of this node:

//Before this line getting executed the parent node should be initialized by adding atleast one element
for(int i=0;i<wdContext.nodeChildValueNode.size();i++)
{
wdContext.nodeChildValueNode().getChildValueNodeElementAt(i).getValueAtt1OfChildValueNode();
}

Non singleton child node:

ParentValueNode
-------------ValueAtt1OfParentValueNode
------------->ChildValueNode(singleton=false)
----------------------->ValueAtt1OfChildValueNode

How to populate the elements of this node:

IPrivateTestView.IParentValueNodeElement parentElement=wdContext.createParentValueNodeElement();
parentElement.setValueAtt1OfParentValueNode("ParentValue1");

//Before this line getting executed the parent node should be initialized by adding atleast one element
//Here you can create a seperate node instace for each and every element of parent node element
IPrivateTestNewView.IChildValueNodeElement childElement=
parentElement.nodeChildValueNode().createChildValueNodeElement();
childElement.setValueAtt1OfChildValueNode("ChildValue1");

How to access the elements of this node:

//Before this line getting executed the parent node should be initialized by adding atleast one element
int size=wdContext.currentParentValueNodeElement().nodeChildValueNode().size();
for(int i=0;i<size;i++)
{
wdContext.currentParentValueNodeElement().nodeChildValueNode().getChildValueNodeElementAt(i).getValueAtt1OfChildValueNode();
}

Regards,

Charan

Former Member
0 Kudos

Hi,

Nodes:

By default if you create any node under Root node directly the singleton property of the node will be set to true

(you can't modif this).

If you create a singleton/ non singleton child node under that node.

If you create a singleton node as child node:

There will be only one instance for that that node at runtime for all the elements of parent node.

ParentValueNode

-


ValueAtt1OfParentValueNode

-


>ChildValueNode(singleton=true)

-


>ValueAtt1OfChildValueNode

How to populate the elements of this node:

IPrivateTestView.IParentValueNodeElement parentElement=wdContext.createParentValueNodeElement();

parentElement.setValueAtt1OfParentValueNode("ParentValue1");

//Before this line getting executed the parent node should be initialized by adding atleast one element

IPrivateTestNewView.IChildValueNodeElement childElement=

wdContext.createChildValueNodeElement();

childElement.setValueAtt1OfChildValueNode("ChildValue1");

How to access the elements of this node:

//Before this line getting executed the parent node should be initialized by adding atleast one element

for(int i=0;i<wdContext.nodeChildValueNode.size();i++)

{

wdContext.nodeChildValueNode().getChildValueNodeElementAt(i).getValueAtt1OfChildValueNode();

}

If you create a non singleton node as child node:

There will be a seperate instance for each and every element of parent node element at runtime.

ParentValueNode

-


ValueAtt1OfParentValueNode

-


>ChildValueNode(singleton=false)

-


>ValueAtt1OfChildValueNode

How to populate the elements of this node:

IPrivateTestView.IParentValueNodeElement parentElement=wdContext.createParentValueNodeElement();

parentElement.setValueAtt1OfParentValueNode("ParentValue1");

//Before this line getting executed the parent node should be initialized by adding atleast one element

//Here you can create a seperate node instace for each and every element of parent node element

IPrivateTestNewView.IChildValueNodeElement childElement=

parentElement.nodeChildValueNode().createChildValueNodeElement();

childElement.setValueAtt1OfChildValueNode("ChildValue1");

How to access the elements of this node:

//Before this line getting executed the parent node should be initialized by adding atleast one element

int size=wdContext.currentParentValueNodeElement().nodeChildValueNode().size();

for(int i=0;i<size;i++)

{

wdContext.currentParentValueNodeElement().nodeChildValueNode().getChildValueNodeElementAt(i).getValueAtt1OfChildValueNode();

}

Former Member
0 Kudos

Hi,

Ignore my earlier reply...

Regards,

Saleem

Former Member
0 Kudos

Hello Marcos,

Node A and B have the same attributes and the sequence is the same.

Regards,

Motaz

Former Member
0 Kudos

Try this code

wdContext.nodeB().getElementAt(wdContext.nodeA().getLeadSelection())

All the best

Marcos

Former Member
0 Kudos

Hi Motaz

Can you give more details about your issue?

The Node A and B have the same attributes and values? If yes, the sequence of this attributes are the same or can change?

Regards

Marcos