Skip to Content
author's profile photo Former Member
Former Member

Elements of a Node

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?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 13, 2006 at 09:41 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Jun 13, 2006 at 09:57 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.