🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.python
3 messages
3 total messages Started by Jordan Szubert Tue, 02 Mar 2010 18:59
czemu nie dziala?
#27338
Author: Jordan Szubert
Date: Tue, 02 Mar 2010 18:59
33 lines
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?
#27339
Author: Bart Ogryczak
Date: Fri, 05 Mar 2010 15:42
9 lines
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?
#27340
Author: Ɓukasz Rekucki
Date: Fri, 05 Mar 2010 19:51
19 lines
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