Creating Other Node Types

Of course, the XmlDocument class provides methods for creating every node type. Table 11.2 lists the additional System.Xml.XmlNodeTypes and their corresponding creation methods.

Table 11.2. Other XmlNodeTypes and Their Creation Methods
NODETYPECREATION METHOD
CDATACreateCDataSection(string data)
CommentCreateComment(string data)
DocumentFragmentCreateDocumentFragment()
EntityReferenceCreateEntityReference(string name)
ProcessingInstructionCreateProcessingInstruction(string target, string data)
WhitespaceCreateWhitespace(string ws)
TextCreateTextNode(string text)
SignificantWhitespaceCreateSignificantWhitespace(string ws)

The CreateEntityReference method must be handled with care. The method will accept any legal name that can ...

Get Microsoft® .NET Compact Framework Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.