Validating XML in Windows

bsneddon bsneddon at yahoo.com
Sun Jul 8 13:46:44 EDT 2007


On Jul 8, 12:22 pm, Stefan Behnel <stefan.behnel-n05... at web.de> wrote:
> Omari Norman wrote:
> > My app needs to validate XML. That's easy enough in Unix. What is the
> > best way to do it in Windows?
>
> > The most obvious choice would of course be PyXML. However, apparently it
> > is no longer maintained:
>
> >http://sourceforge.net/project/showfiles.php?group_id=6473
>
> > so there are no Windows binaries that work with Python 2.5. Getting
> > other XML libraries like libxml2 also seems to be quite difficult on
> > Windows.
>
> > Has anyone else dealt with this problem and found a solution? It would
> > even be fine if I could find a free command-line validator that I could
> > invoke with subprocess, but I haven't even had luck with that.
>
> lxml has statically built  Windows binaries available for version 1.2.1, those
> for 1.3.2 should become available soon. It supports RelaxNG, XMLSchema, DTDs
> and (with a little patching) Schematron.
>
> http://codespeak.net/lxml/
>
> Stefan

You might try something like this.  I am sure you can find help on
MSDN.
I know DOM may not be most efficient but could be a way to solve the
problem
on windows.
>>> import win32com.client
>>>
>>> import win32com.client
>>> objXML = win32com.client.Dispatch("MSXML2.DOMDocument.3.0")
>>> objXML.load(r'C:\data\pyexamples\xml\acro.xml')
True
# not sure how to load schema but there must be away
>>> objXML.validate()




More information about the Python-list mailing list