<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head><style>p {margin:0px;padding:0px;} blockquote { border: 0px; margin-top: 0px; margin-bottom: 0px; }</style></head><body style="">
<p>Hi,<br><font color="#000000" face="Verdana" size="2"><br><blockquote type="cite">> it's not related to XPath, it's just that you change the order of the children<br>> in your test:<br>> <br>> -------------------------<br>> import lxml.etree<br>> import lxml.objectify<br>> <br>> [...]<br>> <br>> gives the same result. I don't even think it's related to objectify.</blockquote></font></p><p> </p><p><font color="#000000" face="Verdana" size="2">Yep, right. Here's without any objectify-ism:</font></p><p> </p><p><font color="#000000" face="Verdana" size="2">>>> from lxml import etree<br>>>><br>>>> xml = etree.fromstring(<br>... '<a xmlns:py="http://codespeak.net/lxml/objectify/pytype">'<br>... '<b name="b1"><title py:pytype="str">tit</title><text>foo</text></b>'<br>... '<b name="b2"><text>bar</text></b></a>')<br>>>><br>>>> print etree.tostring(xml, pretty_print=True)<br><a xmlns:py="http://codespeak.net/lxml/objectify/pytype"><br> <b name="b1"><br> <title py:pytype="str">tit</title><br> <text>foo</text><br> </b><br> <b name="b2"><br> <text>bar</text><br> </b><br></a><br>>>><br>>>> foo = xml[0]<br>>>> bar = xml[1]<br>>>><br>>>> print etree.tostring(xml, pretty_print=True)<br><a xmlns:py="http://codespeak.net/lxml/objectify/pytype"><br> <b name="b1"><br> <title py:pytype="str">tit</title><br> <text>foo</text><br> </b><br> <b name="b2"><br> <text>bar</text><br> </b><br></a><br>>>><br>>>> xml[0] = bar<br>>>> xml.append(foo)<br>>>><br>>>> print etree.tostring(xml, pretty_print=True)<br><a xmlns:py="http://codespeak.net/lxml/objectify/pytype"><br> <b name="b2"><br> <text>bar</text><br> </b><br> <b name="b1"><br> <title pytype="str">tit</title><br> <text>foo</text><br> </b><br></a><br>>>><br>>>> print etree.__version__<br>2.0.alpha4<br>>>><br>>>> </font></p><p> </p><p>FWIW this also fails with older versions, but:</p><p> </p><p>- 1.2.1 fails with the objectify version, but not the "pure" etree one</p><p>- 1.3beta fails with the objectify version, but not the "pure" etree one</p><p> </p><p>Holger </p><p> </p><p></p><p><font></font></p><p></p><p></p><div class="signature"><br /><br /><br />-- <br />GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.<br />Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail</div></body></html>