XML DOM

J

Jay Dorsey

Carlo said:
Hi all,
when I try to Parse a sample XML ducument Python display the follow error
message:
---------------------------------------------------------------------------
Traceback (most recent call last):
File "./mysql.py", line 57, in ?
DOM=xml.dom.minidom.parseString(XML)
File "/usr/local/lib/python2.3/xml/dom/minidom.py", line 1925, in
parseString
return expatbuilder.parseString(string)
File "/usr/local/lib/python2.3/xml/dom/expatbuilder.py", line 940, in
parseString
return builder.parseString(string)
File "/usr/local/lib/python2.3/xml/dom/expatbuilder.py", line 223, in
parseString
parser.Parse(string, True)
xml.parsers.expat.ExpatError: mismatched tag: line 1, column 112
----------------------------------------------------------------------------

I used xml.dom.minodom module and the source code is:


#!/usr/local/bin/python

import xml.dom.minidom

XML="""<?xml version="1.0"?><tabedata><row><EMPLOYEE_ID>55></EMPLOYEE_ID>
<FIRST>Carlo</FIRST><LAST>Sette</LAST></row></tabledata>"""

I would guess that its either the misspelling of the first <tabledata>
tag (missing an L), or the unescaped > sign right after the 55. If
these were typos when you transcribed to the e-mail, check your
script--you might have other typos in your XML string.

Also, I believe entity names are generally lowercase; i.e. <employee_id>
vs. <EMPLOYEE_ID>. I don't work w/ XML enough to recall if this is
required or not; so disregard if I'm way off base :)


Jay
 
C

Carlo Sette

Hi all,
when I try to Parse a sample XML ducument Python display the follow error
message:
---------------------------------------------------------------------------
Traceback (most recent call last):
File "./mysql.py", line 57, in ?
DOM=xml.dom.minidom.parseString(XML)
File "/usr/local/lib/python2.3/xml/dom/minidom.py", line 1925, in
parseString
return expatbuilder.parseString(string)
File "/usr/local/lib/python2.3/xml/dom/expatbuilder.py", line 940, in
parseString
return builder.parseString(string)
File "/usr/local/lib/python2.3/xml/dom/expatbuilder.py", line 223, in
parseString
parser.Parse(string, True)
xml.parsers.expat.ExpatError: mismatched tag: line 1, column 112
----------------------------------------------------------------------------

I used xml.dom.minodom module and the source code is:


#!/usr/local/bin/python

import xml.dom.minidom

XML="""<?xml version="1.0"?><tabedata><row><EMPLOYEE_ID>55></EMPLOYEE_ID>
<FIRST>Carlo</FIRST><LAST>Sette</LAST></row></tabledata>"""


DOM=xml.dom.minidom.parseString(XML)

----------------------------------------------------------------------------

Do you have any suggestions??

Thanks in advance


Carlo
 
D

Dietrich Epp

On Nov 7, 2003, at 5:17 AM, Carlo Sette wrote:

[snip]
xml.parsers.expat.ExpatError: mismatched tag: line 1, column 112
[snip]

XML="""<?xml
version="1.0"?><tabedata><row><EMPLOYEE_ID>55></EMPLOYEE_ID>
<FIRST>Carlo</FIRST><LAST>Sette</LAST></row></tabledata>"""

That's not XML, but it's close. There's a '>' after the 55. Also, it
says 'tabedata' instead of 'tabledata' in the opening root tag.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top