Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
46fa39ab
Kaydet (Commit)
46fa39ab
authored
Şub 06, 2001
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add toprettyxml method into minidom, closes patch #103471.
üst
9e1fe1ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
14 deletions
+24
-14
minidom.py
Lib/xml/dom/minidom.py
+24
-14
No files found.
Lib/xml/dom/minidom.py
Dosyayı görüntüle @
46fa39ab
...
...
@@ -85,6 +85,13 @@ class Node(_Node):
self
.
writexml
(
writer
)
return
writer
.
getvalue
()
def
toprettyxml
(
self
,
indent
=
"
\t
"
,
newl
=
"
\n
"
):
# indent = the indentation string to prepend, per level
# newl = the newline string to append
writer
=
_get_StringIO
()
self
.
writexml
(
writer
,
""
,
indent
,
newl
)
return
writer
.
getvalue
()
def
hasChildNodes
(
self
):
if
self
.
childNodes
:
return
1
...
...
@@ -512,8 +519,11 @@ class Element(Node):
def
__repr__
(
self
):
return
"<DOM Element:
%
s at
%
s>"
%
(
self
.
tagName
,
id
(
self
))
def
writexml
(
self
,
writer
):
writer
.
write
(
"<"
+
self
.
tagName
)
def
writexml
(
self
,
writer
,
indent
=
""
,
addindent
=
""
,
newl
=
""
):
# indent = current indentation
# addindent = indentation to add to higher levels
# newl = newline string
writer
.
write
(
indent
+
"<"
+
self
.
tagName
)
attrs
=
self
.
_get_attributes
()
a_names
=
attrs
.
keys
()
...
...
@@ -524,12 +534,12 @@ class Element(Node):
_write_data
(
writer
,
attrs
[
a_name
]
.
value
)
writer
.
write
(
"
\"
"
)
if
self
.
childNodes
:
writer
.
write
(
">
"
)
writer
.
write
(
">
%
s"
%
(
newl
)
)
for
node
in
self
.
childNodes
:
node
.
writexml
(
writer
)
writer
.
write
(
"
</
%
s>"
%
self
.
tagName
)
node
.
writexml
(
writer
,
indent
+
addindent
,
addindent
,
newl
)
writer
.
write
(
"
%
s</
%
s>
%
s"
%
(
indent
,
self
.
tagName
,
newl
)
)
else
:
writer
.
write
(
"/>
"
)
writer
.
write
(
"/>
%
s"
%
(
newl
)
)
def
_get_attributes
(
self
):
return
AttributeList
(
self
.
_attrs
,
self
.
_attrsNS
)
...
...
@@ -550,8 +560,8 @@ class Comment(Node):
Node
.
__init__
(
self
)
self
.
data
=
self
.
nodeValue
=
data
def
writexml
(
self
,
writer
):
writer
.
write
(
"
<!--
%
s-->"
%
self
.
data
)
def
writexml
(
self
,
writer
,
indent
=
""
,
addindent
=
""
,
newl
=
""
):
writer
.
write
(
"
%
s<!--
%
s-->
%
s"
%
(
indent
,
self
.
data
,
newl
)
)
class
ProcessingInstruction
(
Node
):
nodeType
=
Node
.
PROCESSING_INSTRUCTION_NODE
...
...
@@ -563,8 +573,8 @@ class ProcessingInstruction(Node):
self
.
target
=
self
.
nodeName
=
target
self
.
data
=
self
.
nodeValue
=
data
def
writexml
(
self
,
writer
):
writer
.
write
(
"
<?
%
s
%
s?>"
%
(
self
.
target
,
self
.
data
))
def
writexml
(
self
,
writer
,
indent
=
""
,
addindent
=
""
,
newl
=
""
):
writer
.
write
(
"
%
s<?
%
s
%
s?>
%
s"
%
(
indent
,
self
.
target
,
self
.
data
,
newl
))
class
Text
(
Node
):
nodeType
=
Node
.
TEXT_NODE
...
...
@@ -598,8 +608,8 @@ class Text(Node):
self
.
data
=
self
.
data
[:
offset
]
return
newText
def
writexml
(
self
,
writer
):
_write_data
(
writer
,
self
.
data
)
def
writexml
(
self
,
writer
,
indent
=
""
,
addindent
=
""
,
newl
=
""
):
_write_data
(
writer
,
"
%
s
%
s
%
s"
%
(
indent
,
self
.
data
,
newl
)
)
def
_nssplit
(
qualifiedName
):
fields
=
_string
.
split
(
qualifiedName
,
':'
,
1
)
...
...
@@ -737,10 +747,10 @@ class Document(Node):
_getElementsByTagNameHelper
(
self
,
name
,
rc
)
return
rc
def
writexml
(
self
,
writer
):
def
writexml
(
self
,
writer
,
indent
=
""
,
addindent
=
""
,
newl
=
""
):
writer
.
write
(
'<?xml version="1.0" ?>
\n
'
)
for
node
in
self
.
childNodes
:
node
.
writexml
(
writer
)
node
.
writexml
(
writer
,
indent
,
addindent
,
newl
)
def
_get_StringIO
():
# we can't use cStringIO since it doesn't support Unicode strings
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment