cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to access child node attributes

Former Member
0 Kudos

Hi

I have a parent node and a child node:

ParentNode
      |-->ChildNode
                  |-->Attribute1
                  |-->Attribute2

Cardinality of ParentNode is 0..n and is bound to a structure.

The cardinality of the child node is 1..1, singleton = false and not bound to any structure.

So i assume that exactly one instance of the child node is going to be present for every instance of the parent node

In my code where I populate the ParentNode, I also have to set the attributes in the child node for that instance of the parentnode created. I also have not bound the structure to the node programatically. is this necessary?

But when I access the child node to set the attributes, it gives me runtime error message:

You must not access child nodes before the element is bound to a node

What could be wrong?

Thanks for all help in advance

Madhan

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos
IParentNodeElement parent = wdContext.nodeParentNode().createParentNodeElement();
wdContext.nodeParentNode().addElement(parent);
parent.nodeChildNode().currentChildNodeElement().setAttribute1(<value>);

Make sure that ChildNode.selection = 1:1 too.

Armin

Former Member
0 Kudos

hi,

Check out this code.

wdContext.node<parentnode>.get<parentnode>element.node<childnode>.get<childnode>element.get<attribute>();

Regards,

Gopi

Former Member
0 Kudos

Hi Madhan,

create element for the parent node then add it.

after adding it try to create a elements for child node.

sample code:

Iprivate<virename>.ipaerntnode obj = wdContext.createParentNode();

wdcontext.nodeParentNode().addelement(obj);

now create child node elemts

Iprivate<virename>.iChildnode obj1 = wdcontext.createChildNode();

wdContext.currentParentNodeElement().childNode().addElement(obj1);

Hope this helps

With Regards

Naidu