How to check whether the element is present or not in xml

Hi friends,
I have an xml file in which i have to check whether the element is present or not
Here is the xml format:-

<MultimapPresentation version=“1.0.41” client=“dealerdirect”> <locationData type=“storefinder”> <locationCount>1</locationCount> <totalRecords>1</totalRecords <prevPageUrl /> <nextPageUrl /> <location id=“1”> <record> <param name=“busid”>2640</param> <param name=“zip”>06374-2034</param> <param name=“url”>http://www.google.ca</param> <param name=“preown”>1</param> </record> </location> </locationData> </MultimapPresentation>

Here i have to check whether the totalcount is present or not

Regards,

1 Like

for beginners
have a look at this
for advanced,
take a look at using xpath

@Rup_1 If your requirement is to just check if that element exists and need not do any xml manipulation or extract the value, then you can consider the entire xml as strin and do a string contains to find if totalCount exists or not in that string. XPATH or other xml manipulation is required only if you want to use the value of the xml or do some xml actions.