Closed dyst5422 closed 4 years ago
Sure, that definitely sounds like a good idea. Do you have any ideas about how the API should handle comments? The current Element
type isn't currently well suited for this right now
Yeah. I've written some similar style parsers before. I think you should have other types alongside the element type for comments, text, and cdata. And the children of any element is an enum of those and elements. That way you can preserve order and have multiple of the comment and cdata types.
enum XMLItem {
Element(Element),
Text(String),
Comment(String),
CData(String),
}
struct Element {
children: Vec<XMLItem>
..
}
I recognize this would be a breaking change, but currently, you can't preserve order for text as it is - which can be a problem in some xml use cases (though probably not a good guarantee for people to bet on). Personally, I think an XML lib should produce identical output (save whitespace) to what it takes in.
Perhaps also processing instructions
Opened #18 to cover this. Would love to know if this looks like an appropriate solution to you
It seems that comments are currently skipped. Would you be open to discussions of handling those comments?