on 06-13-2006 10:28 AM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.