Thread View: pl.comp.lang.python
3 messages
3 total messages
Started by Jordan Szubert
Tue, 02 Mar 2010 18:59
czemu nie dziala?
Author: Jordan Szubert
Date: Tue, 02 Mar 2010 18:59
Date: Tue, 02 Mar 2010 18:59
33 lines
1942 bytes
1942 bytes
>>> import sys
>>> sys.version
'3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)]'
>>> from xml.dom.minidom import parseString
>>> T=parseString("""<html xmlns="http://www.w3.org/1999/xhtml"
>>> xml:lang="pl">
... <head>
... <title>{}</title>
... </head>
... <body>
... <ul id="menu">
... </ul>
... <ul xml:id="posty">
... </ul>
... </body>
... </html>""")
>>> T
<xml.dom.minidom.Document object at 0x014189F0>
>>> T.getElementById('menu')
>>> T.getElementById('posty')
>>> print(T.toxml())
<?xml version="1.0" ?><html xml:lang="pl"
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{}</title>
</head>
<body>
<ul id="menu">
</ul>
<ul xml:id="posty">
</ul>
</body>
</html>
Re: czemu nie dziala?
Author: Bart Ogryczak
Date: Fri, 05 Mar 2010 15:42
Date: Fri, 05 Mar 2010 15:42
9 lines
1500 bytes
1500 bytes
On Mar 2, 7:59Â pm, "Jordan Szubert" <n...@podam.na.razie> wrote:
> <xml.dom.minidom.Document object at 0x014189F0>
> >>> T.getElementById('menu')
> >>> T.getElementById('posty')
Pierwsze jest oczywiste, nie dziaĆa bo id to html:id="menu", drugie..
dobre pytanie.
Powinno dziaĆaÄ.
Re: czemu nie dziala?
Author: Ćukasz Rekucki
Date: Fri, 05 Mar 2010 19:51
Date: Fri, 05 Mar 2010 19:51
19 lines
1843 bytes
1843 bytes
On Mar 5, 4:42Â pm, Bart Ogryczak <b.ogryc...@gmail.com> wrote:
> On Mar 2, 7:59Â pm, "Jordan Szubert" <n...@podam.na.razie> wrote:
>
> > <xml.dom.minidom.Document object at 0x014189F0>
> > >>> T.getElementById('menu')
> > >>> T.getElementById('posty')
>
> Pierwsze jest oczywiste, nie dziaĆa bo id to html:id="menu",
Nie id="" to id. DomyĆlna przestrzeĆ nazw nie odnosi siÄ do
atrybutĂłw.
> drugie.. dobre pytanie.
> Powinno dziaĆaÄ.
MoĆŒe by dziaĆaĆo, gdyby minidom obsĆugiwaĆ xml:id. Gdyby umiaĆ czytaÄ
DTD, to i pierwsze by dziaĆaĆo.
Polecam lxml i ElementTree: http://gist.github.com/323066
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads