2

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

5
  • 1
    why not paste out the content of CONFIGATION.xml? Commented Feb 7, 2010 at 14:56
  • Yeah man show us some xml man! Commented Feb 7, 2010 at 14:57
  • 1
    I'm not sure I want to see 474 lines of XML here. Commented Feb 7, 2010 at 14:57
  • Please don't paste the entire contents! 474+ lines will be a lot to sort through. Just paste the contents near line 474. Commented Feb 7, 2010 at 14:57
  • guys i just want to know what does ( not well-formed ) mean what are the well formed XMLs ? Commented Feb 7, 2010 at 15:25

3 Answers 3

2

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".

Sign up to request clarification or add additional context in comments.

1 Comment

one more thing ( that @ was to show the tags in this page ) i didn't put @ in my code
2

"Well-formed XML" means the document conforms to the W3C standards. The error message means your document does not meet those standards for some reason. For instance, those <EXTRA TYPE> tags are illegal because they contain spaces.

Read an overview like this one at Developer.com.

Comments

0

Check to see if your document has any errors on line 474, column 15. There is probably a clue at or near that point.

Also, did you misspell CONFIGURATION? You are missing a 'U'.

3 Comments

He probably didn't misspell it (in the sense of not specifying a valid file) since it read the file correctly.
what does (Well formed document) mean anyway ? does it mean . that i have no closed tags ??? i checked it. and it was fine i guess .
@John, yeah, I just wanted to remind him his config file is spelled wrong besides this bug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.