fn write_node_to_string(self, result: &mut WString) {
        // TODO: we convert some strings to utf8, replacing unpaired surrogates by the replacement char.
        // It is correct?

        let children: Vec<_> = self.children().collect();

        match &*self.0.read() {
            XmlNodeData::DocumentRoot { .. } => {}
            XmlNodeData::Element {
                tag_name,
                attributes,
                ..
            } => {
                result.push_byte(b'<');
                result.push_str(tag_name);

                for (key, value) in attributes {
                    result.push_byte(b' ');
                    result.push_str(key);
                    result.push_str(WStr::from_units(b"=\""));
                    let encoded_value = value.to_utf8_lossy();
                    let escaped_value = escape(encoded_value.as_bytes());
                    result.push_str(WStr::from_units(&*escaped_value));
                    result.push_byte(b'"');
                }

                if children.is_empty() {
                    result.push_str(WStr::from_units(b" />"));
                } else {
                    result.push_byte(b'>');
                }
            }
            XmlNodeData::Text { contents, .. } => {
                let encoded = contents.to_utf8_lossy();
                let escaped = escape(encoded.as_bytes());
                result.push_str(WStr::from_units(&*escaped));
            }
        }

        for child in &children {
            child.write_node_to_string(result);
        }

        match &*self.0.read() {
            XmlNodeData::DocumentRoot { .. } => {}
            XmlNodeData::Element { tag_name, .. } => {
                if !children.is_empty() {
                    result.push_str(WStr::from_units(b"</"));
                    result.push_str(tag_name);
                    result.push_byte(b'>');
                }
            }
            XmlNodeData::Text { .. } => {}
        }
    }
/// Write the contents of this node, including its children, to the given string.
Write the contents of this node, including its children, to the given string.
Write the contents of this node including its children to the given string .
fn write_node_to_string(self, result: &mut WString) {
        // TODO: we convert some strings to utf8, replacing unpaired surrogates by the replacement char.
        // It is correct?
        let children: Vec<_> = self.children().collect();
        match &*self.0.read() {
            XmlNodeData::DocumentRoot { .. } => {}
            XmlNodeData::Element {
                tag_name,
                attributes,
                ..
            } => {
                result.push_byte(b'<');
                result.push_str(tag_name);
                for (key, value) in attributes {
                    result.push_byte(b' ');
                    result.push_str(key);
                    result.push_str(WStr::from_units(b"=\""));
                    let encoded_value = value.to_utf8_lossy();
                    let escaped_value = escape(encoded_value.as_bytes());
                    result.push_str(WStr::from_units(&*escaped_value));
                    result.push_byte(b'"');
                }
                if children.is_empty() {
                    result.push_str(WStr::from_units(b" />"));
                } else {
                    result.push_byte(b'>');
                }
            }
            XmlNodeData::Text { contents, .. } => {
                let encoded = contents.to_utf8_lossy();
                let escaped = escape(encoded.as_bytes());
                result.push_str(WStr::from_units(&*escaped));
            }
        }
        for child in &children {
            child.write_node_to_string(result);
        }
        match &*self.0.read() {
            XmlNodeData::DocumentRoot { .. } => {}
            XmlNodeData::Element { tag_name, .. } => {
                if !children.is_empty() {
                    result.push_str(WStr::from_units(b"</"));
                    result.push_str(tag_name);
                    result.push_byte(b'>');
                }
            }
            XmlNodeData::Text { .. } => {}
        }
    }
fn write_node_to_string ( self , result : & mut WString ) { // TODO: we convert some strings to utf8, replacing unpaired surrogates by the replacement char. // It is correct? let children : Vec < _ > = self . children ( ) . collect ( ) ; match & * self . 0 . read ( ) { XmlNodeData :: DocumentRoot { .. } => { } XmlNodeData :: Element { tag_name , attributes , .. } => { result . push_byte ( b'<' ) ; result . push_str ( tag_name ) ; for ( key , value ) in attributes { result . push_byte ( b' ' ) ; result . push_str ( key ) ; result . push_str ( WStr :: from_units ( b" \" " ) ) ; let encoded_value = value . to_utf8_lossy ( ) ; let escaped_value = escape ( encoded_value . as_bytes ( ) ) ; result . push_str ( WStr :: from_units ( & * escaped_value ) ) ; result . push_byte ( b'"' ) ; } if children . is_empty ( ) { result . push_str ( WStr :: from_units ( b" " ) ) ; } else { result . push_byte ( b'>' ) ; } } XmlNodeData :: Text { contents , .. } => { let encoded = contents . to_utf8_lossy ( ) ; let escaped = escape ( encoded . as_bytes ( ) ) ; result . push_str ( WStr :: from_units ( & * escaped ) ) ; } } for child in & children { child . write_node_to_string ( result ) ; } match & * self . 0 . read ( ) { XmlNodeData :: DocumentRoot { .. } => { } XmlNodeData :: Element { tag_name , .. } => { if ! children . is_empty ( ) { result . push_str ( WStr :: from_units ( b" " ) ) ; result . push_str ( tag_name ) ; result . push_byte ( b'>' ) ; } } XmlNodeData :: Text { .. } => { } } }
Write the contents of this node, including its children, to the given string.
Write the contents of this node including its children to the given string .
self
result
&mut WString