Search code examples
xmlparsingxml-parsingmarkup

Cannot determine what is invalid with my very simple XML


I have an XML string that validators are saying is invalid. The error occurs on line 2 character 1. The string is all at the same tier. It is about a hundred occurences of <map> and map has various attributes.

<map attribute_1="thomas"></map>
<map attribute_1="thomas again"></map>

That's the entire string. But I'm being told that

Line 1: Can not find declaration of element 'map'.
Line 2: The markup in the document following the root element must be well-formed.

Based on what I read in this answer, I thought that perhaps <map> needs a parent element which shares a name attribute with a child. I copy pasted the structure so I ended up with something like

<element name="details">
    <complexType>
        <sequence>
            <map name="details">
            </map>
        </sequence>
    </complexType>
</element>

It was just a shot in the dark, as my experience with XML is nil. In any case, it didn't work. What's wrong with my markup?


Solution

  • Your XML should be like

    <?xml version="1.0" encoding="UTF-8"?>
    <maps>
    <map attribute_1="thomas"></map>
    <map attribute_1="thomas again"></map>
    </maps>
    

    try this