[Tutor] Problems with Minidom XML Parser

Andy Osagie andy_osagie@hotmail.com
Mon Jun 2 19:17:03 2003


This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C3293B.6515E990
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello,=20
I seem to have trouble editing the values of parsed XML documents so =
that I can save them with my new values.


>>> from xml.dom import minidom
>>> doc =3D minidom.parseString("<entry>random stuff</entry>")
>>> doc.childNodes[0].toxml()
u'<entry>random stuff</entry>'
>>> doc.childNodes[0].nodeName
u'entry'
>>> doc.childNodes[0].nodeValue
>>> doc.childNodes[0].nodeName =3D "new"
>>> doc.childNodes[0].nodeValue =3D "test value"
>>> doc.childNodes[0].toxml()
u'<entry>random stuff</entry>'


I can't really figure out the problem. Is there any way to accomplish =
what I've tried above? I'm trying to make a simple XML driven database.

Thanks in advance,
Andy Osagie
------=_NextPart_000_0007_01C3293B.6515E990
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello, </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I seem to have trouble editing the =
values of parsed=20
XML documents so that I can save them with my new values.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; from xml.dom import=20
minidom</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; doc =3D=20
minidom.parseString("&lt;entry&gt;random =
stuff&lt;/entry&gt;")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; =
doc.childNodes[0].toxml()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>u'&lt;entry&gt;random=20
stuff&lt;/entry&gt;'</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt;=20
doc.childNodes[0].nodeName</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>u'entry'</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt;=20
doc.childNodes[0].nodeValue</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; doc.childNodes[0].nodeName =
=3D=20
"new"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; =
doc.childNodes[0].nodeValue =3D "test=20
value"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; =
doc.childNodes[0].toxml()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>u'&lt;entry&gt;random=20
stuff&lt;/entry&gt;'</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I can't really figure out the problem. =
Is there any=20
way to accomplish what I've tried above? I'm trying to make a simple XML =
driven=20
database.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Andy Osagie</FONT></DIV></BODY></HTML>

------=_NextPart_000_0007_01C3293B.6515E990--