[XML-SIG] newbie question on loading/saving xml files

Mark Humphrey mark.humphrey@acm.org
Tue, 23 Oct 2001 10:19:00 -0500


--4SFOXa2GPu3tIq4H
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Oct 23, 2001 at 02:02:49AM -0700, Mariappan, MaharajanX wrote:
> Hi Folks,
>=20
> I just now start searching for documents for expat modules.
>=20
> I want to=20
> * load a xml file and show in GUI using python and
> * save the xml files in disk=20
>=20
> I went through=20
>=20
>  <<DOM.html.url>>=20
> as Alexander told earlier, But I couldn't make out=20
>=20
> Pointer to any documents with examples will really help me

I'm checking my own code for this.  Seems like these are the functions that=
 you're wanting:

	Printer.PrintVisitor(...)
- and -
	FromXMLStream(...)

Writing works something like this:

	printer =3D Printer.PrintVisitor(f, 'UTF-8')
	printer.visit(domTree)

Here, f is an output file stream.  In my particular case,
	f =3D open(..., 'w')

You'll need to do this...
	from xml.dom.ext import Printer
=2E..to get this object.

The FromXMLStream function takes a file stream as an input and outputs a DO=
M tree, if the file stream was properly structured XML.  You get to it with:
	from xml.dom.ext.reader.Sax import FromXmlStream

After that, everything you do just consists of DOM tree manipulations, and =
you should be able to find good documentation on the DOM from the w3c web s=
ite (www.w3c.org).  PyXML has an odd mix of DOM level 1 and level 2 functio=
ns implemented, and I think I've even found a few random level 3 functions =
have been implemented.  Not sure what the exact pattern is, though.

--=20
Mark "Markus" Humphrey		mark.humphrey@acm.org
http://galadriel.ath.cx:88/
GPG Public Key A54BC06F, available on www.keyserver.net
If you can't say anything bad about Microsoft, don't say anything at all.

--4SFOXa2GPu3tIq4H
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE71YpkP3ikGaVLwG8RAhGaAJ9Ck1QtwI154xkJkyRfZqf8dTgePgCg4hPt
C+3qXm1a3cHxCGqY8j7tgz8=
=jxku
-----END PGP SIGNATURE-----

--4SFOXa2GPu3tIq4H--