XML DOM

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carlo Sette

    XML DOM

    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.min idom.parseStrin g(XML)
    File "/usr/local/lib/python2.3/xml/dom/minidom.py", line 1925, in
    parseString
    return expatbuilder.pa rseString(strin g)
    File "/usr/local/lib/python2.3/xml/dom/expatbuilder.py ", line 940, in
    parseString
    return builder.parseSt ring(string)
    File "/usr/local/lib/python2.3/xml/dom/expatbuilder.py ", line 223, in
    parseString
    parser.Parse(st ring, True)
    xml.parsers.exp at.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>Set te</LAST></row></tabledata>"""


    DOM=xml.dom.min idom.parseStrin g(XML)

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

    Do you have any suggestions??

    Thanks in advance


    Carlo
  • Richard Brodie

    #2
    Re: XML DOM


    "Carlo Sette" <c.sette_NOSPAM _@reddevils.it> wrote in message
    news:bog62a$1do ch3$1@ID-198142.news.uni-berlin.de...
    [color=blue]
    > xml.parsers.exp at.ExpatError: mismatched tag: line 1, column 112
    >[/color]
    Problem seems to be around column 112:
    [color=blue][color=green][color=darkred]
    >>> XML[110:130][/color][/color][/color]
    '</tabledata>'

    Can't find a match for the tabledata close tag, why is that?
    [color=blue]
    > XML="""<?xml version="1.0"?> <tabedata><row> <EMPLOYEE_ID>55 ></EMPLOYEE_ID>...[/color]

    Oops. Spelt it differently in the open tag.


    Comment

    • Dietrich Epp

      #3
      Re: XML DOM


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

      [snip]
      [color=blue]
      > xml.parsers.exp at.ExpatError: mismatched tag: line 1, column 112[/color]

      [snip]
      [color=blue]
      > XML="""<?xml
      > version="1.0"?> <tabedata><row> <EMPLOYEE_ID>55 ></EMPLOYEE_ID>
      > <FIRST>Carlo</FIRST><LAST>Set te</LAST></row></tabledata>"""[/color]

      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.


      Comment

      • Jay Dorsey

        #4
        Re: XML DOM

        Carlo Sette wrote:[color=blue]
        > 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.min idom.parseStrin g(XML)
        > File "/usr/local/lib/python2.3/xml/dom/minidom.py", line 1925, in
        > parseString
        > return expatbuilder.pa rseString(strin g)
        > File "/usr/local/lib/python2.3/xml/dom/expatbuilder.py ", line 940, in
        > parseString
        > return builder.parseSt ring(string)
        > File "/usr/local/lib/python2.3/xml/dom/expatbuilder.py ", line 223, in
        > parseString
        > parser.Parse(st ring, True)
        > xml.parsers.exp at.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>Set te</LAST></row></tabledata>"""[/color]

        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


        Comment

        • Carlo Sette

          #5
          Re: XML DOM

          Thank you all,
          my XML document is corrupted....
          Sorry.

          Carlo

          Comment

          Working...