xmlnon-well-formed

python xml error


I'm new to xml. I'm trying to parse an xml file to extract data from, but it shows the error below message when I call doc=minidom.parse('D:\\CONFIGRATION.xml') ...

xml.parsers.expat.ExpatError:not well-formed (invalid token): line 474, column 15

473 <Extras>
474    <extra Type>
475      jpg
476    </extra Type>
477    <extra Type>
478      psd
479    </extra Type>
480 </Extras>

Can anyone please help me? What is a well-formed XML document?

Thanks in advance


Solution

  • You ask what "well-formed" means. It means that the XML conforms to the standard. Not being "well-formed" means you've used illegal syntax. In your specific case you have a tag that looks like:

    <@extra Type>
    

    You can't have a space in your tag name. You have other problems as well -- you can't start a tag with @, and your closing tags are also wrong. The slash needs to immediately follow the <

    The official specification for well-formed XML is on the W3C website. your xml against the specification. If you want more detailed information about your document you can use one of many xml validation services. Use your favorite search engine to search for "xml validation".