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 18 additions and 15 deletions
|
@ -31,15 +31,17 @@ pub struct Element {
|
|||
|
||||
impl fmt::Debug for Element {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
if let Some(ref ns) = self.namespace {
|
||||
write!(fmt, "<{{{}}}{}", ns, self.name)?;
|
||||
}
|
||||
else {
|
||||
write!(fmt, "<{}", self.name)?;
|
||||
if let Some(ref ns) = self.namespace {
|
||||
write!(fmt, " xmlns=\"{}\"", ns)?;
|
||||
}
|
||||
for attr in &self.attributes {
|
||||
write!(fmt, " {}", attr)?;
|
||||
}
|
||||
if self.children.is_empty() {
|
||||
write!(fmt, "/>")?;
|
||||
}
|
||||
else {
|
||||
write!(fmt, ">")?;
|
||||
for child in &self.children {
|
||||
match *child {
|
||||
|
@ -52,6 +54,7 @@ impl fmt::Debug for Element {
|
|||
}
|
||||
}
|
||||
write!(fmt, "</{}>", self.name)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue