cancel
Showing results for 
Search instead for 
Did you mean: 

Getting currently selected element of context node

Former Member
0 Kudos

hi All

i hav another query for you regarding the manipulation of table.

how do v get the currentcontextelement since the node table refering to is at 3rd level e.g.

parent--

child1--

-


child2---

-


attribute1

-


attribute2

now way m getting current value for attribute1 is as follwos

IWDNode parent=wdContext.nodeParent.currentParentNodeElement.node();

child1=parent.getchild("child1",parent.getLeadselection());

child2=child1.getchild("child2",parent.getLeadselection());

attribute1 = child2.getCurrentElement().getAttributeAsText("attribute1");

is there any other simpler way for this????

Thanks

Deeps

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

You can directly get the child attribute as

wdContext.currentAttribute();

Former Member
0 Kudos

Really?

Armin

Former Member
0 Kudos

Hey All

thanks for help.

bye the way Armin is there any different way to access the attribute in case of non-singleton node??

Thanks & Regard

Deeps

Former Member
0 Kudos

It depends on what you want to access. When using wdContext.current<Node>Element(), the path from the root element to the node is followed along the lead-selection of all intermediate nodes.

But sometimes you want to access for example the lead-selection in a child node whose parent element is not lead-selected. And in that case you have to do it differently.

Armin

Former Member
0 Kudos

Are any nodes in this structure non-singleton? Do you really want to access the node element of "child2" following the lead-selection-path from the root?

Armin

former_member485701
Active Participant
0 Kudos

Hi

Following line will always return you the selected Element for the corresponding Node.

IWDNodeElement selectedElem=wdContext.current<Node Name>Element();

Regards,

Praveen

Former Member
0 Kudos

Hi,

You can access it using:

wdContext.nodeChild2().currentChild2Element().getattribute1();

wdContext.nodeChild2().currentChild2Element().getattribute2();

I mean to say that you can directly access the child nodes using the above code. You dont need to go from the parent node.

thanks & regards,

Manoj

sid_sunny
Contributor
0 Kudos

Hi Deepak,

Use this:

wdContext.currentChild2Element().getAttribute1();

and to get any element use this:

wdContext.nodeChild2().getChild2ElementAt(x).getAttribute1();

Regards

sid

Edited by: siddharth chauhan on Jan 14, 2008 3:14 PM