I have an XML which is a response from a third party API and can have multiple root elements.
Is there a way to check that XML response contains multiple root elements, so that I can wrap it in a parent element else parse it normally.
I know how to handle if there are multiple root elements but how to know if they are in multiple as currently when load the xml document in doc.load it gives me error.
The API response can be with multiple root elements or sometimes it can be a single root element.
Possible response can be :
<myroot>
<foo>
</foo>
</myroot>
<myotherroot>
<bar>
</bar>
</myotherroot>
or
<parent>
<myroot>
<foo>
</foo>
</myroot>
<myotherroot>
<bar>
</bar>
</myotherroot>
</parent>