cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if the node is null or empty?

Former Member
0 Kudos

I need to know how one can check whether if a node is empty. I have five attributes in the node. But instead of checking each element, i just want to check if all the attributes are empty are not.

Any help will be appreciated.

Thanks

Nahman

Accepted Solutions (0)

Answers (3)

Answers (3)

lajitha_menon
Contributor
0 Kudos

Hi there,

> I need to know how one can check whether if a node is

> empty.

- You can check if a node has elements by checking size(). If size = 0, node is empty i.e it has no elements

I have five attributes in the node. But

> instead of checking each element, i just want to

> check if all the attributes are empty are not.

If the current element exists, and you need to check whether the attribute in that element is null or not, then you need to know the attribute name. If there are too many attributes, you can consider putting all of them in an array and then iterating through the array with getAttributeValue(Arrayelement), to get each value and then checking that for null.

Regards,

LM

Former Member
0 Kudos

Hi Nahman ,

If you want to check only whether node is null then you can do that as mentioned above.

If you want to check whether the attributes are null or not then

for(int i=0;i<wdContext.nodeXXX().size;i++)

{

IPrivate<ViewName>.IXXXElement ele=(IPrivate<ViewName>.IXXXElement)wdContext.nodeXXX().getElementAt(i);

if(null !=ele.getAttributeValue("<<AttributeName>>") )

{

//

}

else

if(ele.getAttributeValue("<<AttributeName>>") .trim().equals(""))

{

//

}

}

Regards, Anilkumar

former_member185029
Active Contributor
0 Kudos

hi

try this


if(wdContext.nodeMyNode()!=null && wdContext.nodeMyNode().size()!=0)
{
}

Ashutosh