Merge branch 'valid-xml' into 'master'
Make the Debug trait output valid XML See merge request !1
This commit is contained in:
commit
8f027cfee2
1 changed files with 17 additions and 14 deletions
|
|
@ -31,27 +31,30 @@ pub struct Element {
|
||||||
|
|
||||||
impl fmt::Debug for Element {
|
impl fmt::Debug for Element {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(fmt, "<{}", self.name)?;
|
||||||
if let Some(ref ns) = self.namespace {
|
if let Some(ref ns) = self.namespace {
|
||||||
write!(fmt, "<{{{}}}{}", ns, self.name)?;
|
write!(fmt, " xmlns=\"{}\"", ns)?;
|
||||||
}
|
|
||||||
else {
|
|
||||||
write!(fmt, "<{}", self.name)?;
|
|
||||||
}
|
}
|
||||||
for attr in &self.attributes {
|
for attr in &self.attributes {
|
||||||
write!(fmt, " {}", attr)?;
|
write!(fmt, " {}", attr)?;
|
||||||
}
|
}
|
||||||
write!(fmt, ">")?;
|
if self.children.is_empty() {
|
||||||
for child in &self.children {
|
write!(fmt, "/>")?;
|
||||||
match *child {
|
}
|
||||||
Node::Element(ref e) => {
|
else {
|
||||||
write!(fmt, "{:?}", e)?;
|
write!(fmt, ">")?;
|
||||||
},
|
for child in &self.children {
|
||||||
Node::Text(ref s) => {
|
match *child {
|
||||||
write!(fmt, "{}", s)?;
|
Node::Element(ref e) => {
|
||||||
},
|
write!(fmt, "{:?}", e)?;
|
||||||
}
|
},
|
||||||
|
Node::Text(ref s) => {
|
||||||
|
write!(fmt, "{}", s)?;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write!(fmt, "</{}>", self.name)?;
|
||||||
}
|
}
|
||||||
write!(fmt, "</{}>", self.name)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue