[pyar] consulta parseo sencillo de .xml

Alejandro Santos listas en alejolp.com
Jue Mar 12 06:53:13 ART 2015


2015-03-11 16:28 GMT+01:00 Mariano AM <marianoamx en gmail.com>:
> Adjunté el .xml como pidieron, me podrán dar una manito?
>

Tu XML está malformado, tenés un <!ELEMENT x repetido con x dos veces.
Ejemplo, "footer" está repetido:

>>> dom = parseString(A)
>>>
>>> A="""<?xml version="1.0" encoding="UTF-8"?>
...
... <!DOCTYPE note
... [
... <!ELEMENT note (to,from,heading,body)>
... <!ELEMENT to (#PCDATA)>
... <!ELEMENT from (#PCDATA)>
... <!ELEMENT heading (#PCDATA)>
... <!ELEMENT body (#PCDATA)>
... <!ELEMENT footer (#PCDATA)>
... <!ELEMENT footer (#PCDATA)>
... ]>
...
... <note>
... <to>Tove</to>
... <from>Jani</from>
... <heading>Reminder</heading>
... <body>Don't forget me this weekend!</body>
... <footer>aaa</footer>
... </note> """
>>>
>>> dom = parseString(A)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/xml/dom/minidom.py", line 1928, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib64/python2.6/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib64/python2.6/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
  File "/usr/lib64/python2.6/xml/dom/expatbuilder.py", line 437, in
element_decl_handler
    assert info._model is None
AssertionError



-- 
Alejandro Santos


More information about the pyar mailing list