cancel
Showing results for 
Search instead for 
Did you mean: 

Elements of a Node

Former Member
0 Kudos

Hi,

i have a Context Node this node has several value attributes...

And i want to get all values from one of this attributes.

Is there a way to iterate only trough a single attribute of the node and not trough all attributes?

Or does somebody know another way to solve this problem?

Accepted Solutions (1)

Accepted Solutions (1)

vijayakhanna_raman
Active Contributor
0 Kudos

Hi,

Get the size of the node .

Using the for loop

int size=wdContest.node<node name>.size();

wdContest.node<node name>..MoveFirst();

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

String test=wdGetContext().current<node name>.Element().get<Attribute1 name>();

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("User Name:"+test);

wdContest.node<node name>..MoveNext();

}

Similarly u can get the values of other attributes in the node using this code.

wdGetContext().current<node name>.Element().get<Attribute name>();

Regards,

Vijayakhanna

Former Member
0 Kudos

thank you problem is solved!

Former Member
0 Kudos

It is not necessary to move the lead selection when iterating a node element collection.

This loop would better be written as

for (int i = 0, n = wdContext.node<Node>().size(); i < n; ++i)
{
  I<Node>Element e = wdContext.node<Node>().get<Node>ElementAt(i);
  /* do something with node element e */
}

Armin

Answers (1)

Answers (1)

Former Member
0 Kudos

What do you mean with "iterate only through a single attribute"?

A node (with cardinality 0:N) is a collection of an unbounded number of node elements.

Elements are comparable to records that have attributes.

If you want to get some attribute value for all elements of a node, you should

- iterate over all elements of the node

- get the currently iterated node element

- get the attribute value from that node element

Armin