pub struct XmlDoc {
pub version: String,
pub encoding: Option<String>,
pub standalone: Option<bool>,
pub dtd: Option<XmlDtd>,
/* private fields */
}Expand description
libxml2 xmlDoc.
Fields§
§version: StringXML version string; default "1.0".
encoding: Option<String>Encoding name from the XML declaration, if any.
standalone: Option<bool>Some(true/false) from standalone, None if omitted.
dtd: Option<XmlDtd>Internal / attached DTD, if any.
Implementations§
Source§impl XmlDoc
impl XmlDoc
Sourcepub fn xml_new_doc(version: Option<&str>) -> Self
pub fn xml_new_doc(version: Option<&str>) -> Self
xmlNewDoc.
Sourcepub fn with_node_capacity(version: Option<&str>, cap: usize) -> Self
pub fn with_node_capacity(version: Option<&str>, cap: usize) -> Self
Build a document whose node arena is sized up front. Starting a parse used to allocate the arena, push into it, then reallocate on reserve – three trips for what one sized allocation does. The document node’s name is implied by its kind, so it stores no String either.
Sourcepub fn reserve_nodes(&mut self, n: usize)
pub fn reserve_nodes(&mut self, n: usize)
Pre-size the node arena. XML runs about one node per 10-15 input bytes, so a parser that knows the document length can skip most of the arena’s doubling-and-copy. Capped so a huge document cannot reserve wildly.
pub fn node(&self, id: NodeId) -> &Node
pub fn node_mut(&mut self, id: NodeId) -> &mut Node
pub fn kind(&self, id: NodeId) -> NodeKind
pub fn name(&self, id: NodeId) -> &str
pub fn prefix(&self, id: NodeId) -> Option<&str>
pub fn ns_uri(&self, id: NodeId) -> Option<&str>
pub fn content(&self, id: NodeId) -> &str
pub fn parent(&self, id: NodeId) -> Option<NodeId>
pub fn first_child(&self, id: NodeId) -> Option<NodeId>
pub fn last_child(&self, id: NodeId) -> Option<NodeId>
pub fn next_sibling(&self, id: NodeId) -> Option<NodeId>
pub fn prev_sibling(&self, id: NodeId) -> Option<NodeId>
pub fn first_attr(&self, id: NodeId) -> Option<NodeId>
pub fn ns_defs(&self, id: NodeId) -> &[(Option<String>, String)]
Sourcepub fn alloc_unnamed(&mut self, kind: NodeKind) -> NodeId
pub fn alloc_unnamed(&mut self, kind: NodeKind) -> NodeId
Allocate a node whose name is implied by its kind, storing no String.
XmlDoc::name reports the canonical name for these.
pub fn alloc(&mut self, kind: NodeKind, name: impl Into<String>) -> NodeId
Sourcepub fn xml_doc_get_root_element(&self) -> Option<NodeId>
pub fn xml_doc_get_root_element(&self) -> Option<NodeId>
xmlDocGetRootElement.
Sourcepub fn xml_doc_set_root_element(&mut self, elem: NodeId) -> Option<NodeId>
pub fn xml_doc_set_root_element(&mut self, elem: NodeId) -> Option<NodeId>
xmlDocSetRootElement. Returns the previous root, if any.
Sourcepub fn xml_new_doc_node(
&mut self,
ns_uri: Option<&str>,
name: &str,
content: Option<&str>,
) -> NodeId
pub fn xml_new_doc_node( &mut self, ns_uri: Option<&str>, name: &str, content: Option<&str>, ) -> NodeId
xmlNewDocNode.
Sourcepub fn xml_new_child(
&mut self,
parent: NodeId,
ns_uri: Option<&str>,
name: &str,
content: Option<&str>,
) -> NodeId
pub fn xml_new_child( &mut self, parent: NodeId, ns_uri: Option<&str>, name: &str, content: Option<&str>, ) -> NodeId
xmlNewChild.
Sourcepub fn xml_add_child(&mut self, parent: NodeId, child: NodeId)
pub fn xml_add_child(&mut self, parent: NodeId, child: NodeId)
xmlAddChild.
Sourcepub fn xml_add_next_sibling(&mut self, cur: NodeId, elem: NodeId)
pub fn xml_add_next_sibling(&mut self, cur: NodeId, elem: NodeId)
xmlAddNextSibling.
Sourcepub fn xml_add_prev_sibling(&mut self, cur: NodeId, elem: NodeId)
pub fn xml_add_prev_sibling(&mut self, cur: NodeId, elem: NodeId)
xmlAddPrevSibling.
Sourcepub fn xml_unlink_node(&mut self, id: NodeId)
pub fn xml_unlink_node(&mut self, id: NodeId)
xmlUnlinkNode.
Sourcepub fn xml_replace_node(&mut self, old: NodeId, new: NodeId) -> NodeId
pub fn xml_replace_node(&mut self, old: NodeId, new: NodeId) -> NodeId
xmlReplaceNode.
Sourcepub fn add_attr_owned(
&mut self,
elem: NodeId,
name: String,
prefix: Option<String>,
value: String,
) -> NodeId
pub fn add_attr_owned( &mut self, elem: NodeId, name: String, prefix: Option<String>, value: String, ) -> NodeId
As XmlDoc::add_attr, but takes ownership. The borrowing form has to
allocate a fresh String for the name, the prefix and the value, all of
which the parser already owns.
pub fn add_attr( &mut self, elem: NodeId, name: &str, prefix: Option<&str>, value: &str, ) -> NodeId
pub fn push_ns_def(&mut self, elem: NodeId, prefix: Option<String>, uri: String)
Sourcepub fn xml_has_prop(&self, node: NodeId, name: &str) -> bool
pub fn xml_has_prop(&self, node: NodeId, name: &str) -> bool
xmlHasProp.
Sourcepub fn xml_unset_prop(&mut self, node: NodeId, name: &str) -> bool
pub fn xml_unset_prop(&mut self, node: NodeId, name: &str) -> bool
xmlUnsetProp.
Sourcepub fn xml_node_get_content(&self, id: NodeId) -> String
pub fn xml_node_get_content(&self, id: NodeId) -> String
xmlNodeGetContent — concatenate descendant text/CDATA.
Sourcepub fn xml_node_set_content(&mut self, id: NodeId, content: &str)
pub fn xml_node_set_content(&mut self, id: NodeId, content: &str)
xmlNodeSetContent — replace children with a single text node.
Sourcepub fn xml_is_blank_node(&self, id: NodeId) -> bool
pub fn xml_is_blank_node(&self, id: NodeId) -> bool
xmlIsBlankNode.
Sourcepub fn xml_search_ns(
&self,
node: NodeId,
prefix: Option<&str>,
) -> Option<String>
pub fn xml_search_ns( &self, node: NodeId, prefix: Option<&str>, ) -> Option<String>
xmlSearchNs — walk ancestors for a prefix binding.
Sourcepub fn xml_new_ns(&mut self, node: NodeId, href: &str, prefix: Option<&str>)
pub fn xml_new_ns(&mut self, node: NodeId, href: &str, prefix: Option<&str>)
xmlNewNs — add a namespace declaration on an element.
Sourcepub fn xml_set_ns(
&mut self,
node: NodeId,
href: Option<&str>,
prefix: Option<&str>,
)
pub fn xml_set_ns( &mut self, node: NodeId, href: Option<&str>, prefix: Option<&str>, )
xmlSetNs.
Sourcepub fn xml_copy_doc(&self) -> XmlDoc
pub fn xml_copy_doc(&self) -> XmlDoc
xmlCopyDoc — deep copy.