XmlDocument

XmlDocument class

Represents an XML document. You can use this class to load, validate, edit, add, and position XML in a document.

class XmlDocument : public System::Xml::XmlNode

Methods

MethodDescription
virtual SharedPtr<XmlNode> AppendChild(SharedPtr<XmlNode>)Adds the specified node to the end of the list of child nodes, of this node.
iterator begin()Gets iterator pointing to the first element (if any) of the collection. This iterator can’t be used to change a referenced object because GetEnumerator() returns a copy-object of T.
const_iterator begin() constGets iterator pointing to the first element (if any) of the const-qualified instance of the collection.
const_iterator cbegin() constGets iterator pointing to the first const-qualified element (if any) of the collection.
const_iterator cend() constGets iterator pointing right after the last const-qualified element (if any) of the collection.
virtual SharedPtr<XmlNode> Clone()Creates a duplicate of this node.
SharedPtr<XmlNode> CloneNode(bool) overrideCreates a duplicate of this node.
SharedPtr<XmlAttribute> CreateAttribute(const String&)Creates an XmlAttribute with the specified name.
SharedPtr<XmlAttribute> CreateAttribute(const String&, const String&)Creates an XmlAttribute with the specified qualified name and XmlNode::get_NamespaceURI.
virtual SharedPtr<XmlAttribute> CreateAttribute(const String&, const String&, const String&)Creates an XmlAttribute with the specified XmlNode::get_Prefix, XmlDocument::get_LocalName, and XmlNode::get_NamespaceURI.
virtual SharedPtr<XmlCDataSection> CreateCDataSection(const String&)Creates an XmlCDataSection containing the specified data.
virtual SharedPtr<XmlComment> CreateComment(const String&)Creates an XmlComment containing the specified data.
virtual SharedPtr<XmlDocumentFragment> CreateDocumentFragment()Creates an XmlDocumentFragment.
virtual SharedPtr<XmlDocumentType> CreateDocumentType(const String&, const String&, const String&, const String&)Returns a new XmlDocumentType object.
SharedPtr<XmlElement> CreateElement(const String&)Creates an element with the specified name.
SharedPtr<XmlElement> CreateElement(const String&, const String&)Creates an XmlElement with the qualified name and XmlNode::get_NamespaceURI.
virtual SharedPtr<XmlElement> CreateElement(const String&, const String&, const String&)Creates an element with the specified XmlNode::get_Prefix, XmlDocument::get_LocalName, and XmlNode::get_NamespaceURI.
virtual SharedPtr<XmlEntityReference> CreateEntityReference(const String&)Creates an XmlEntityReference with the specified name.
SharedPtr<XPath::XPathNavigator> CreateNavigator() overrideCreates a new XPathNavigator object for navigating this document.
virtual SharedPtr<XmlNode> CreateNode(XmlNodeType, const String&, const String&, const String&)Creates a XmlNode with the specified XmlNodeType, XmlNode::get_Prefix, XmlDocument::get_Name, and XmlNode::get_NamespaceURI.
virtual SharedPtr<XmlNode> CreateNode(const String&, const String&, const String&)Creates an XmlNode with the specified node type, XmlDocument::get_Name, and XmlNode::get_NamespaceURI.
virtual SharedPtr<XmlNode> CreateNode(XmlNodeType, const String&, const String&)Creates an XmlNode with the specified XmlNodeType, XmlDocument::get_Name, and XmlNode::get_NamespaceURI.
virtual SharedPtr<XmlProcessingInstruction> CreateProcessingInstruction(const String&, const String&)Creates an XmlProcessingInstruction with the specified name and data.
virtual SharedPtr<XmlSignificantWhitespace> CreateSignificantWhitespace(const String&)Creates an XmlSignificantWhitespace node.
virtual SharedPtr<XmlText> CreateTextNode(const String&)Creates an XmlText with the specified text.
virtual SharedPtr<XmlWhitespace> CreateWhitespace(const String&)Creates an XmlWhitespace node.
virtual SharedPtr<XmlDeclaration> CreateXmlDeclaration(const String&, const String&, const String&)Creates an XmlDeclaration node with the specified values.
iterator end()Gets iterator pointing right after the last element (if any) of the collection. This iterator can’t be used to change a referenced object because GetEnumerator() returns a copy-object of T.
const_iterator end() constGets iterator pointing right after the last element (if any) of the const-qualified instance of the collection.
virtual bool Equals(ptr)Compares objects using C# Object.Equals semantics.
static std::enable_if<IsSmartPtr<T1>::value&&IsSmartPtr<T2>::value, bool>::type Equals(T1 const&, T2 const&)Compares reference type objects in C# style.
static std::enable_if<!IsSmartPtr<T1>::value&&!IsSmartPtr<T2>::value, bool>::type Equals(T1 const&, T2 const&)Compares value type objects in C# style.
static bool Equals(float const&, float const&)Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN.
static bool Equals(double const&, double const&)Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN.
virtual bool FastCast(const Details::FastRttiBase&, void **) constFor internal purposes only.
virtual SharedPtr<XmlAttributeCollection> get_Attributes()Returns an XmlAttributeCollection containing the attributes of this node.
String get_BaseURI() overrideReturns the base URI of the current node.
virtual SharedPtr<XmlNodeList> get_ChildNodes()Returns all the child nodes of the node.
SharedPtr<XmlElement> get_DocumentElement()Returns the root XmlElement for the document.
virtual SharedPtr<XmlDocumentType> get_DocumentType()Returns the node containing the DOCTYPE declaration.
virtual SharedPtr<XmlNode> get_FirstChild()Returns the first child of the node.
virtual bool get_HasChildNodes()Returns a value indicating whether this node has any child nodes.
SharedPtr<XmlImplementation> get_Implementation()Returns the XmlImplementation object for the current document.
virtual String get_InnerText()Returns the concatenated values of the node and all its child nodes.
String get_InnerXml() overrideReturns the markup representing the children of the current node.
bool get_IsReadOnly() overrideReturns a value indicating whether the current node is read-only.
virtual SharedPtr<XmlNode> get_LastChild()Returns the last child of the node.
String get_LocalName() overrideReturns the local name of the node.
String get_Name() overrideReturns the qualified name of the node.
virtual String get_NamespaceURI()Returns the namespace URI of this node.
SharedPtr<XmlNameTable> get_NameTable()Returns the XmlNameTable associated with this implementation.
virtual SharedPtr<XmlNode> get_NextSibling()Returns the node immediately following this node.
XmlNodeType get_NodeType() overrideReturns the type of the current node.
virtual String get_OuterXml()Returns the markup containing this node and all its child nodes.
SharedPtr<XmlDocument> get_OwnerDocument() overrideReturns the XmlDocument to which the current node belongs.
virtual SharedPtr<XmlNode> get_ParentNode()Returns the parent of this node (for nodes that can have parents).
virtual String get_Prefix()Returns the namespace prefix of this node.
bool get_PreserveWhitespace()Returns a value indicating whether to preserve white space in element content.
virtual SharedPtr<XmlNode> get_PreviousSibling()Returns the node immediately preceding this node.
virtual SharedPtr<XmlNode> get_PreviousText()Returns the text node that immediately precedes this node.
SharedPtr<Schema::IXmlSchemaInfo> get_SchemaInfo() overrideReturns the Post-Schema-Validation-Infoset (PSVI) of the node.
SharedPtr<Schema::XmlSchemaSet> get_Schemas()Returns the XmlSchemaSet object associated with this XmlDocument.
virtual String get_Value()Returns the value of the node.
Detail::SmartPtrCounter * GetCounter()Gets reference counter data structure associated with the object.
virtual SharedPtr<XmlElement> GetElementById(String)Returns the XmlElement with the specified ID.
virtual SharedPtr<XmlNodeList> GetElementsByTagName(String)Returns an XmlNodeList containing a list of all descendant elements that match the specified name.
virtual SharedPtr<XmlNodeList> GetElementsByTagName(String, String)Returns an XmlNodeList containing a list of all descendant elements that match the specified XmlDocument::get_LocalName and XmlNode::get_NamespaceURI.
SharedPtr<Collections::Generic::IEnumerator<SharedPtr<XmlNode>>> GetEnumerator() overrideReturns an enumerator that iterates through the child nodes in the current node.
virtual int32_t GetHashCode() constAnalog of C# Object.GetHashCode() method. Enables hashing of custom objects.
virtual String GetNamespaceOfPrefix(String)Looks up the closest xmlns declaration for the given prefix that is in scope for the current node and returns the namespace URI in the declaration.
virtual String GetPrefixOfNamespace(String)Looks up the closest xmlns declaration for the given namespace URI that is in scope for the current node and returns the prefix defined in that declaration.
virtual const TypeInfo& GetType() constGets actual type of object. Analog of C# System.Object.GetType() call.
virtual SharedPtr<XmlElement> idx_get(String)Returns the first child element with the specified XmlNode::get_Name.
virtual SharedPtr<XmlElement> idx_get(String, String)Returns the first child element with the specified XmlNode::get_LocalName and XmlNode::get_NamespaceURI values.
virtual SharedPtr<XmlNode> ImportNode(SharedPtr<XmlNode>, bool)Imports a node from another document to the current document.
virtual SharedPtr<XmlNode> InsertAfter(SharedPtr<XmlNode>, SharedPtr<XmlNode>)Inserts the specified node immediately after the specified reference node.
virtual SharedPtr<XmlNode> InsertBefore(SharedPtr<XmlNode>, SharedPtr<XmlNode>)Inserts the specified node immediately before the specified reference node.
virtual bool Is(const TypeInfo&) constCheck if object represents an instance of type described by targetType. Analog of C# ‘is’ operator.
T LINQ_Aggregate(const Func<T, T, T>&)Applies an accumulator function over a sequence.
bool LINQ_All(std::function<bool(T)>)Determines whether all elements of a sequence satisfy a condition.
bool LINQ_Any()Determines whether a sequence contains any elements.
bool LINQ_Any(std::function<bool(T)>)Determines whether any element of a sequence exists or satisfies a condition.
SharedPtr<IEnumerable<ResultType>> LINQ_Cast()Casts the elements to the specified type.
SharedPtr<IEnumerable<Result>> LINQ_Cast()
SharedPtr<IEnumerable<T>> LINQ_Concat(SharedPtr<IEnumerable<T>>)Concatenates two sequences.
bool LINQ_Contains(T)Determines if a sequence contains a specified value.
int LINQ_Count()Returns the number of elements in the sequence (calculated via direct counting).
int LINQ_Count(const Func<T, bool>&)Returns the number of elements in the sequence that satisfy the specified condition.
T LINQ_ElementAt(int)Returns the element at a specified index in a sequence.
T LINQ_ElementAtOrDefault(int)Returns the element at a specified index in a sequence.
T LINQ_First()Returns the first element of a sequence.
T LINQ_First(const Func<T, bool>&)Returns the first element of a sequence that satisfy the specified condition.
T LINQ_FirstOrDefault()Returns the first element of a sequence, or a default value if the sequence is empty.
T LINQ_FirstOrDefault(std::function<bool(T)>)Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
System::SharedPtr<IEnumerable<System::SharedPtr<System::Linq::IGrouping<Key, T>>>> LINQ_GroupBy(System::Func<T, Key>)Groups the elements of a sequence.
SharedPtr<IEnumerable<SharedPtr<System::Linq::IGrouping<Key, Source>>>> LINQ_GroupBy(System::Func<Source, Key>)
T LINQ_Last()Returns the last element of a sequence.
T LINQ_LastOrDefault()Returns the last element of a sequence, or a default value if the sequence is empty.
ResultType LINQ_Max(const Func<T, ResultType>&)Invokes a transform function on each element of a generic sequence and returns the maximum resulting value.
ResultType LINQ_Max(const Func<Source, ResultType>&)
ResultType LINQ_Min(const Func<T, ResultType>&)Invokes a transform function on each element of a generic sequence and returns the minimum resulting value.
ResultType LINQ_Min(const Func<Source, ResultType>&)
SharedPtr<IEnumerable<ResultType>> LINQ_OfType()Filters the elements of the sequence based on the specified type.
SharedPtr<IEnumerable<Result>> LINQ_OfType()
SharedPtr<Linq::IOrderedEnumerable<T>> LINQ_OrderBy(const Func<T, Key>&)Sorts the elements of a sequence in ascending order according to the key values selected by keySelector.
SharedPtr<Linq::IOrderedEnumerable<Source>> LINQ_OrderBy(const Func<Source, Key>&)
SharedPtr<Linq::IOrderedEnumerable<T>> LINQ_OrderByDescending(const Func<T, Key>&)Sorts the elements of a sequence in descending order according to the key values selected by keySelector.
SharedPtr<Linq::IOrderedEnumerable<Source>> LINQ_OrderByDescending(const Func<Source, Key>&)
SharedPtr<IEnumerable<T>> LINQ_Reverse()Inverts the order of the elements in a sequence.
SharedPtr<IEnumerable<ResultType>> LINQ_Select(const Func<T, ResultType>&)Transforms elements of a sequence.
SharedPtr<IEnumerable<ResultType>> LINQ_Select(const Func<T, int32_t, ResultType>&)Transforms each element of a sequence into a new form by incorporating the element’s index.
SharedPtr<IEnumerable<Result>> LINQ_Select(const Func<Source, Result>&)
SharedPtr<IEnumerable<Result>> LINQ_Select(const Func<Source, int32_t, Result>&)
SharedPtr<IEnumerable<ResultType>> LINQ_SelectMany(const Func<T, SharedPtr<IEnumerable<ResultType>>>&)Projects each element of a sequence and combines the resulting sequences into one sequence.
SharedPtr<IEnumerable<Result>> LINQ_SelectMany(const Func<Source, SharedPtr<IEnumerable<Result>>>&)
SharedPtr<IEnumerable<T>> LINQ_Take(int32_t)Returns a specified number of contiguous elements from the start of a sequence.
System::ArrayPtr<T> LINQ_ToArray()Creates an array from a sequence.
SharedPtr<List<T>> LINQ_ToList()Creates a List from a sequence.
SharedPtr<IEnumerable<T>> LINQ_Where(std::function<bool(T)>)Filters a sequence based on the specified predicate.
virtual void Load(String)Loads the XML document from the specified URL.
virtual void Load(SharedPtr<IO::Stream>)Loads the XML document from the specified stream.
virtual void Load(SharedPtr<IO::TextReader>)Loads the XML document from the specified TextReader.
virtual void Load(SharedPtr<XmlReader>)Loads the XML document from the specified XmlReader.
virtual void LoadXml(String)Loads the XML document from the specified string.
void Lock()Implements C# lock() statement locking. Call directly or use LockContext sentry object.
virtual ptr MemberwiseClone() constAnalog of C# Object.MemberwiseClone() method. Enables cloning custom types.
virtual void Normalize()Puts all XmlText nodes in the full depth of the sub-tree underneath this XmlNode into a "normal" form where only markup (that is, tags, comments, processing instructions, CDATA sections, and entity references) separates XmlText nodes, that is, there are no adjacent XmlText nodes.
Object()Creates object. Initializes all internal data structures.
Object(Object const&)Copy constructor. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses.
Object& operator=(Object const&)Assignment operator. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses.
virtual SharedPtr<XmlNode> PrependChild(SharedPtr<XmlNode>)Adds the specified node to the beginning of the list of child nodes for this node.
virtual SharedPtr<XmlNode> ReadNode(SharedPtr<XmlReader>)Creates an XmlNode object based on the information in the XmlReader. The reader must be positioned on a node or attribute.
static bool ReferenceEquals(ptr const&, ptr const&)Compares objects by reference.
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, T const&)Compares objects by reference.
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, std::nullptr_t)Reference-compares value type object with nullptr.
bool ReferenceEquals(String const&, std::nullptr_t)Specialization of Object::ReferenceEquals for case of string and nullptr.
bool ReferenceEquals(String const&, String const&)Specialization of Object::ReferenceEquals for case of strings.
virtual void RemoveAll()Removes all the child nodes and/or attributes of the current node.
virtual SharedPtr<XmlNode> RemoveChild(SharedPtr<XmlNode>)Removes specified child node.
int RemovedSharedRefs(int)Decreases shared reference count by specified value.
virtual SharedPtr<XmlNode> ReplaceChild(SharedPtr<XmlNode>, SharedPtr<XmlNode>)Replaces the child node oldChild with newChild node.
virtual void Save(String)Saves the XML document to the specified file. If the specified file exists, this method overwrites it.
virtual void Save(SharedPtr<IO::Stream>)Saves the XML document to the specified stream.
virtual void Save(SharedPtr<IO::TextWriter>)Saves the XML document to the specified TextWriter.
virtual void Save(SharedPtr<XmlWriter>)Saves the XML document to the specified XmlWriter.
SharedPtr<XmlNodeList> SelectNodes(const String&)Selects a list of nodes matching the XPath expression.
SharedPtr<XmlNodeList> SelectNodes(const String&, const SharedPtr<XmlNamespaceManager>&)Selects a list of nodes matching the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied XmlNamespaceManager.
SharedPtr<XmlNode> SelectSingleNode(const String&)Selects the first XmlNode that matches the XPath expression.
SharedPtr<XmlNode> SelectSingleNode(const String&, const SharedPtr<XmlNamespaceManager>&)Selects the first XmlNode that matches the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied XmlNamespaceManager.
void set_InnerText(String) overrideThrows an InvalidOperationException in all cases.
void set_InnerXml(String) overrideSets the markup representing the children of the current node.
virtual void set_Prefix(String)Sets the namespace prefix of this node.
void set_PreserveWhitespace(bool)Sets a value indicating whether to preserve white space in element content.
void set_Schemas(const SharedPtr<Schema::XmlSchemaSet>&)Sets the XmlSchemaSet object associated with this XmlDocument.
virtual void set_Value(String)Sets the value of the node.
virtual void set_XmlResolver(SharedPtr<System::Xml::XmlResolver>)Sets the XmlResolver to use for resolving external resources.
virtual void SetTemplateWeakPtr(uint32_t)Set n’th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode.
int SharedCount() constGets current value of shared reference counter.
Object * SharedRefAdded()Increments shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
int SharedRefRemovedSafe()Decrements and returns shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
virtual bool Supports(String, String)Tests if the DOM implementation implements a specific feature.
virtual String ToString() constAnalog of C# Object.ToString() method. Enables converting custom objects to string.
static const TypeInfo& Type()Implements C# typeof(System.Object) construct.
void Unlock()Implements C# lock() statement unlocking. Call directly or use LockContext sentry object.
void Validate(Schema::ValidationEventHandler)Validates the XmlDocument against the XML Schema Definition Language (XSD) schemas contained in the XmlDocument::get_Schemas list.
void Validate(Schema::ValidationEventHandler, const SharedPtr<XmlNode>&)Validates the XmlNode object specified against the XML Schema Definition Language (XSD) schemas in the XmlDocument::get_Schemas list.
virtual virtualized_iterator * virtualizeBeginConstIterator() constGets the implementation of begin const iterator for the current container.
virtual virtualized_iterator * virtualizeBeginIterator()Gets the implementation of begin iterator for the current container.
virtual virtualized_iterator * virtualizeEndConstIterator() constGets the implementation of end const iterator for the current container.
virtual virtualized_iterator * virtualizeEndIterator()Gets the implementation of end iterator for the current container.
Detail::SmartPtrCounter * WeakRefAdded()Increments weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
void WeakRefRemoved()Decrements weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
void WriteContentTo(const SharedPtr<XmlWriter>&) overrideSaves all the children of the XmlDocument node to the specified XmlWriter.
void WriteTo(const SharedPtr<XmlWriter>&) overrideSaves the XmlDocument node to the specified XmlWriter.
XmlDocument()Initializes a new instance of the XmlDocument class.
XmlDocument(const SharedPtr<XmlNameTable>&)Initializes a new instance of the XmlDocument class with the specified XmlNameTable.
virtual ~Object()Destroys object. Frees all internal data structures.

Typedefs

TypedefDescription
PtrAn alias for shared pointer to an instance of this class.

Remarks

Objects of this class should only be allocated using System::MakeObject() function. Never create instances of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.

See Also