cancel
Showing results for 
Search instead for 
Did you mean: 

read node element directly with matching criterion

Former Member
0 Kudos

Hi all,

Is there anyway that u directly read a node element whose value attribute is say 'AAA' without looping throgh all the node elements.

For example i have Student data node with value attrubutes id,name,etc.

now for this node i want to read the element with id 'A1234'.

instead of getting the size of the node and looping through the entire node and match the id, i want a method which returns the corresponding node element which satisfies the criterion.

Thanks

Vijaya

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hello Vijaya,

AFAIK, there is no direct way. As workaround you can create map context attribute, iterate through node elements and store attribute (id) as key and node element as value. The problem is that you have to create such map for every attribute you need.

Best regards, Maksim Rashchynski.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

It is possible to get the att value inside the node using the method <b>getElement("String name")</b>.

Hope this helps u,

Regards,

Nagarajan.

former_member182372
Active Contributor
0 Kudos

Hello Nagarajan,

What kind of thing are you talking about? What is "attribute value inside the node"? Element inside the node you can access through getCurrentElement(), getElementAt(int index), move*() methods.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/javadocs/nw04/sp12/web dynpro runtime environment/com/sap/tc/webdynpro/progmodel/api/iwdnode.html .

Attributes inside element you can access through getAttributeValue(String attributeName), getAttributeAsText(String attributeName) methods.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/javadocs/nw04/sp12/web dynpro runtime environment/com/sap/tc/webdynpro/progmodel/api/iwdnodeelement.html

Attributes you can access through IWDNodeInfo class and getAttribute(String name) method

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/javadocs/nw04/sp12/web dynpro runtime environment/com/sap/tc/webdynpro/progmodel/api/iwdnodeinfo.html

But, what is "att value inside the node" ?

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

hi nagarjuna,

can u pl little elaborate on this code. suppose

the node structure is as follows and it contains data in it.

Student (node)

|_ id (value Attributes)

|_ name

|_ address

instead of the following code

String Code = "A1234";

max = wdContext.nodeStudent.size();

for(int i = 0; i < max ; i++)

{

IStudentElement student = wdContext.nodeStudent().getStudentsElementAt(i);

if(Code.equals(student.getId())

{

// do some process

}

}

here the node contains only entry with id. so i neither want to loop through the entire elements nor break once the there is success, if there is any other method.

Thanks in advance

Vijaya

Former Member
0 Kudos

hi Vijayalakshmi,

I don't think it is possible to do what you want without looping through the elements.

Regards

Rohit

Former Member
0 Kudos

you can use the break java statement inside the if inside the for

String Code = "A1234";

max = wdContext.nodeStudent.size();

for(int i = 0; i < max ; i++)

{

IStudentElement student = wdContext.nodeStudent().getStudentsElementAt(i);

if(Code.equals(student.getId())

{

// do some process

break; //this will end the for(...) when you find the student

}

}