05-29-06 10:21 PM
Your xpath query looks a bit weird. Please try:
count(/Company/Emp[1]/ECertified)
Maybe that will do the trick. At least count should return 0 if the
element isn't there, but make sure that there's at least one Emp
element, else it probably won't work!
Sander
Jayendra wrote:
> Hi,
>
> I need to check the existence of optional filed,Could anyone help me on
> this.
> In the below input file,i want to wheather elment <ECertified>Exists or
not.
>
> I have tried in my way,But it is throwing exception in case elment
> doesn't exist.
> xpath>>Count(//Company//Emp[1]//ECertified).
>
>
>
>
> i/p file:
> <Company>
>
> <Emp>
> <Eno>1</ENo>
> <EName>AAA</Ename>
> </Emp>
>
> <Emp>
> <Eno>2</ENo>
> <EName>bbb</Ename>
> <ECertified>Yes</ECertified>
> </Emp>
>
>
> </Company>
>
>
>
> Thanks,
> Prakash
[ Post a follow-up to this message ]
|