Implement text nodes / content escaping

This removes the support for re-indenting XML, but allows to faithfully
parse / stringify a document. Beautification could be added again later
on if desired.
This commit is contained in:
Felix Geisendörfer 2013-09-10 23:18:13 +02:00
parent 08c0943149
commit b3124cf4a7
4 changed files with 57 additions and 39 deletions

View file

@ -117,7 +117,9 @@ func (this *Document) LoadStream(r io.Reader, charset CharsetFunc) (err error) {
case xml.SyntaxError:
return errors.New(tt.Error())
case xml.CharData:
ct.Value = ct.Value + strings.TrimSpace(string([]byte(tt)))
t := NewNode(NT_TEXT)
t.Value = string([]byte(tt))
ct.AddChild(t)
case xml.Comment:
t := NewNode(NT_COMMENT)
t.Value = strings.TrimSpace(string([]byte(tt)))