pub struct XmlDocument<S> { /* private fields */ }Expand description
An immutable XML tree whose nodes reference ranges in source whenever possible.
S may be &[u8], Arc<[u8]>, Vec<u8>, or another byte container.
Implementations§
Source§impl<S: AsRef<[u8]>> XmlDocument<S>
impl<S: AsRef<[u8]>> XmlDocument<S>
Sourcepub fn parse(source: S) -> Result<Self, Error>
pub fn parse(source: S) -> Result<Self, Error>
Parses a complete XML document with the default bounded policy.
§Errors
Returns an error when the source violates the default safety policy, is malformed, or contains invalid XML data or encoding.
Sourcepub fn parse_with_options(
source: S,
options: &ParseOptions,
) -> Result<Self, Error>
pub fn parse_with_options( source: S, options: &ParseOptions, ) -> Result<Self, Error>
Parses a complete XML document into a flat arena.
§Errors
Returns an error when options is invalid, the source exceeds a configured limit, or the
XML is malformed or has invalid data or encoding.
pub fn source(&self) -> &[u8] ⓘ
pub fn into_source(self) -> S
pub fn root(&self) -> ElementRef<'_, S>
pub fn node(&self, id: NodeId) -> Option<NodeRef<'_, S>>
pub fn node_count(&self) -> usize
pub fn allocated_value_count(&self) -> usize
Source§impl XmlDocument<Arc<[u8]>>
impl XmlDocument<Arc<[u8]>>
Sourcepub fn from_reader<R: Read>(reader: R) -> Result<Self, Error>
pub fn from_reader<R: Read>(reader: R) -> Result<Self, Error>
Reads and parses a complete document with the default bounded policy.
§Errors
Returns an error when reading fails or the input violates the default XML safety and well-formedness contract.
Sourcepub fn from_reader_with_options<R: Read>(
reader: R,
options: &ParseOptions,
) -> Result<Self, Error>
pub fn from_reader_with_options<R: Read>( reader: R, options: &ParseOptions, ) -> Result<Self, Error>
Reads at most one byte beyond the configured limit before parsing an owned document.
§Errors
Returns an error when options is invalid, reading fails, the input exceeds the byte limit,
or the XML violates a configured safety or well-formedness rule.