I am getting an invalid XML error when using $.parseXML() with my string of XML data. The string is:
<query_result>
<row id=1>
<distance>2.835</distance>
<post_title>anywhere</post_title>
<post_excerpt></post_excerpt>
<ID>425</ID>
</row>
<row id=2>
<distance>2.862</distance>
<post_title>nowhere</post_title>
<post_excerpt></post_excerpt>
<ID>435</ID>
</row>
<row id=3>
<distance>2.867</distance>
<post_title>who knows</post_title>
<post_excerpt></post_excerpt>
<ID>429</ID>
</row>
</query_result>
I can't seem to find the reason I am getting this error. anyone care to share some insight? Thanks a lot in advance. EDIT: changed the xml to allow root brackets to match
The opening and closing Tag of the outermost Element do not Match (query_result
vs. result
).
The row
elements' id
attribute values need to be enclosed in double or single quotes.
A well-formed XML document also needs a so-called 'prologue' as the very first line of the file:
<?xml version="1.0" encoding="utf-8"?>