Tree Nodes (XML))
P
IProcessingInstruction
See also: IXmlIdentifier, IXmlToken, IXmlTreeNode
Represents a processing instruction. The Start
and End
properties give access to the tokens that represent the start and end of the processing instruction, namely the <?
and ?>
tokens respectively. The InstructionTargetNode
property is an IXmlIdentifier
that represents the target of the processing instruction, that is, the identifier immediately following the start token. As a convenience, you can get at the text of the target using the InstructionTarget
property, which simply calls GetText()
on the IXmlIdentifier
. Finally, the Body
property is a token that contains the content of the processing instruction, if any. This is a simple XmlToken
containing the text after the target, unparsed. If the instruction contains text that looks like attributes, they are not parsed - the Body
property will contain the full text.
While the <?xml ... ?>
declaration at the start of an XML document shares similar syntax to processing instructions, it is not a processing instruction, and is instead represented using the IXmlProcessingInstruction
interface.
X
IXmlAsteriskTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a token representing the asterisk character (*
).
IXmlAttribute
See also: IXmlAttributeValue, IXmlIdentifier, IXmlToken, IXmlTreeNode
Represents an attribute. The Identifier
property returns the tree node that contains the name of the attribute, and the AttributeName
convenience property will retrieve the full text of the attribute name, including namespace prefix, if applicable.
The XmlName
and XmlNamespace
properties will retrieve the text of the attribute name split into local name and namespace prefix, respectively. E.g. foo:bar="quux"
will return "bar"
for XmlName
and "foo"
for XmlNamespace
. If there is no namespace prefix, an empty string is returned (the XmlNamespace
property is annotated with [NotNull]
).
The XmlNameRange
and XmlNamespaceRange
properties return the ranges of the XmlName
and XmlNamespace
strings relative to the Identifier
node. That is, they are the offsets into AttributeName
.
The Value
property will return the IXmlAttributeValue
node representing the value, while the UnquotedValue
property will return the string value of the attribute, without surround quotes.
Finally, the Eq
property is the token representing the equals sign in the attribute declaration, e.g. name="value"
.
IXmlAttributeContainer
See also: IXmlAttribute, IXmlTreeNode
Represents a node that can contain attributes. This is typically mostly inherited by IXmlTagHeader
, but also by IXmlProcessingInstruction
in order to expose the attributes defined in the XML declaration. The Attributes
collection is pre-iterated and backed by an array, while the AttributesEnumerable
is lazily evaluated.
The ContainerName
property returns the text of the child IXmlIdentifier
node of the container. In other words, for an XML tag, it will return the name of the tag. For an XML declaration, it will return the "xml" part of the <?xml ... ?>
declaration.
IXmlAttributeValue
See also: IXmlTreeNode, IXmlValueToken
Represents the value in an attribute. It is implemented by the XmlValueToken
type, and represents the quoted part of the value in an XML attribute name="value"
. The ValueToken
property provides access to an instance of IXmlValueToken
token that essentially represents the same information (indeed, the XmlValueToken
implementation simply returns this
).
IXmlCData
See also: IXmlToken, IXmlTreeNode
An XML CDATA node. The Start
property is the <![CDATA[
token, and End
is the ]]>
token. While they are listed as IXmlToken
instances, they are in fact, instances of the IXmlCdataStartTokenNode
and IXmlCdataEndTokenNode
marker interfaces. Body
is a token representing the content of the CDATA node, while the CData
property is the content as a plain string.
IXmlCdataEndTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for the CDATA end token ]]>
.
IXmlCdataStartTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for the CDATA start token <![CDATA[
.
IXmlCommaTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a token representing the comma character (,
).
IXmlComment
See also: IXmlCommentNode, IXmlTreeNode
Represents an XML comment. See IXmlCommentNode
.
IXmlCommentEndTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for the XML comment close token -->
.
IXmlCommentNode
See also: IXmlToken, IXmlTreeNode
Represents and XML comment. The CommentStart
and CommentEnd
properties are the start (<!--
) and end (-->
) tokens of the comment. Although listed here as IXmlToken
, they are in fact instances of the IXmlCommentStartTokenNode
and IXmlCommentEndTokenNode
marker interfaces. The comment text is held in the CommentBody
node, and exposed as a string with the CommentText
property.
IXmlCommentStartTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for the XML comment start token <!--
.
IXmlDocumentNode
See also: IXmlTreeNode
Marker interface representing the document node of an XML file. Inherited by IXmlFile
.
IXmlDtdStartTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for the start token (<!DOCTYPE
) of an inline DTD declaration.
IXmlEntityTokenNode
See also: IXmlToken, IXmlTreeNode
An XML entity reference token representing content such as •
or ©
. The IsNumericEntity
property is true if the entity begins with the string &#
. The Name
property is the name of the entity, with the ampersand and semi-colon removed, or null
for numeric entities. That is, ©
will return "copy"
and •
will return null
for Name
.
IXmlEqTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a token representing the equals character (=
).
IXmlFile
The root interface for an XML file. Derives from both IFile
and IXmlTreeNode
. Also derives from IXmlTagContainer
showing that it can have child tags.
Exposes a collection of processing instructions and the collection of element types used by this flavour of XML. See the overview for more information about the element types.
IXmlFloatingTextTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a non-fixed length token, e.g. identifiers, text, entity references or whitespace. Note that the default implementation (XmlFloatingTextToken
) is used for text, while the derived XmlWhitespaceToken
, XmlEntityToken
and XmlIdentifier
are used for the other node types. This is so that they can implement other interfaces, such as IXmlEntityTokenNode
and IXmlIdentifier
. Or in the case of XmlWhitespaceToken
, to override ITreeNode.IsFiltered()
to return true
.
IXmlIdentifier
See also: IXmlToken, IXmlTreeNode
An XML identifier, with optional namespace prefix. The XmlName
property returns the text of the identifier without the namespace prefix, while the XmlNamespace
property returns the prefix, if any. E.g. "foo:bar"
will return "bar"
for XmlName
and "foo"
for XmlNamespace
. If there is no namespace prefix, XmlNamespace
returns an empty string (the property is marked with the [NotNull]
annotation attribute).
The XmlNameRange
and XmlNamespaceRange
properties return the ranges of the namespace and local name, relative to the start of the identifier node. If there is no namespace prefix, the range returned by XmlNamespaceRange
is empty.
IXmlLbracketTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a token representing the left bracket character ([
).
IXmlLparenthTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a token representing the left parenthesis character ((
).
IXmlOrTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a token representing the "or" or "pipe" character (|
).
IXmlPercentTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a token representing the percent character (%
).
IXmlPiendTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for the processing instruction end token ?>
.
IXmlPistartTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for the processing instruction start token <?
.
IXmlPlusTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a token representing the plus character (+
).
IXmlProcessingInstruction
See also: IXmlAttributeContainer, IXmlIdentifier, IXmlToken, IXmlTreeNode
Represents the XML declaration at the start of an XML file, usually of the form:
The StartNode
and EndNode
properties provide the IXmlPistartTokenNode
and IXmlPiendTokenNode
tokens. The Name
property gets the IXmlIdentifier
node that represents the xml
in the declaration.
Access to the attributes is available via the derived IXmlAttributeContainer
interface members.
IXmlQuestionTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a token representing the question mark character (?
).
IXmlRbracketTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a token representing the right bracket character (]
).
IXmlRparenthTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a token representing the right parenthesis character ()
).
IXmlSyntaxErrorElement
Represents a syntax error in the tree. Does not derive from IXmlTreeNode
. The ErrorDescription
property provides textual representation of the error, which can be displayed to the user, e.g. as a tooltip. The ErrorType
property is an instance of XmlSyntaxErrorType
, which can be compared against the static field instances available on the XmlSyntaxErrorType
class.
IXmlTag
See also: IXmlAttribute, IXmlTagContainer, IXmlTagFooter, IXmlTagHeader, IXmlToken, IXmlTreeNode
Represents a complete XML element. The Header
and Footer
properties represent the opening and closing tags of the element. Attributes can be retrieved via the Header
property (see IXmlTagHeader
).
The inner content can be retrieved in several ways:
InnerXml
provides a tree range (relative to the tree) of all nodes after the header, and before the footer, including whitespace. This span will encompass all immediate child nodes (and therefore all descendant nodes, too).InnerText
will return the text from the range returned byInnerXml
. The text will therefore include all child and descendant tags and content.InnerTextTokens
will return all token nodes (seeIXmlToken
) that are deemed to be "text" tokens. It does this by callingIXmlToken.GetTokenType()
and looking that type up in thetag.XmlTokenTypes.TEXT_NODES
set. This set is initialised toXmlTokenTypes.TEXT
,XmlTokenTypes.ENTITY_REF
andXmlTokenTypes.CHAR_REF
. This means, it will include all instances ofIXmlFloatingTextTokenNode
andIXmlEntityTokenNode
.InnerValue
returns a string containing the content of the child text nodes, including text, entity references, whitespace and CDATA nodes. This property will also check to see if whitespace should be preserved, by using theXmlLangaugeSupport.IsSpacePreserved
method to look forxml:space="preserved"
on parent tags.
The IsEmptyTag
property will return true if Header.IsClosed
returns true. That is, if the tag is of the form <foo />
.
The AddAttributeAfter
, AddAttributeBefore
and RemoveAttribute
methods will add or remove attributes from the tag header. Passing null
as the anchor parameter will insert the attribute before the first attribute for AddAttributeAfter
and after the last attribute for AddAttributeBefore
. The attribute must have been created beforehand, using the XmlElementFactory
class. If the tag is part of a physical tree (that is, associated with a file, and not created as part of a sandbox), then the implementations must take the write lock before adding or removing attributes. The modifications can be performed using ModificationUtil.AddChildAfter
, ModificationUtil.AddChildBefore
and ModificationUtil.DeleteRange
.
Child tags can be retrieved and modified using the IXmlTagContainer
derived interface.
IXmlTagContainer
See also: IXmlTag
Represents a node that can contain tags. Mostly inherited by IXmlTag
, but also inherited by IXmlFile
.
This interface provides several means of retrieving child tags. Unless otherwise stated, all tags are immediate children of the current tag. When a method is declared as generic, it will filter the child tags so that they match the type passed in. This type must implement IXmlTag
, and is mostly useful for finding a specific tag when working with XML-derived languages, such as web.config files or build scripts.
The
InnerTags
property provides a (pre-iterated) collection of childIXmlTag
instances.GetTag(Predicate<IXmlTag> predicate)
will return the first child tag that matches the given predicate.GetTags<T>()
will return a lazily-evaluated enumerable of child tags, filtered to instances of the generic typeT
passed to the method.GetTags2<T>()
will return a pre-iterated collection of child tags. It is similar toInnerTags
, except it will filter all instances to the type passed in asT
.GetNestedTags<T>(string xpath)
will return a list ofIXmlTag
instances that match a very simple XPath-like expression. The expression only supports"*"
and"/"
, and must start with a tag name. The implementation (XPathUtil.GetNestedTags<T>()
) will split the path on the"/"
char, and match each path segment. If the path segment is"*"
it will match any tag at that level. It does not provide support for matching attributes or skipping path segments with"//"
. Again, the found tags must also match the type ofT
passed to the method.
The AddTagAfter
, AddTagBefore
and RemoveTag
methods provide means of adding and removing already created tags to the tag container. Implementations will ensure that tag container is not a self-closed tag (using XmlTagUtil.MakeCompound
) and will then use methods in XmlContainerUtil
to add or remove the tags. Implementations will also ensure that the write lock is taken, if the tag container is part of a physical tree (that is, associated with a file, and not a sandbox). Tags can be created using the XmlElementFactory
derived classes.
IXmlTagEnd1TokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for a self-closing XML tag end token />
.
IXmlTagEndTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for an XML tag end token >
.
IXmlTagFooter
See also: IXmlIdentifier, IXmlToken, IXmlTreeNode
Represents the closing tag of an XML element. Not present if the XML tag is self-closing/empty. The StartNode
is an instance of IXmlTagStart1TokenNode
representing the </
and EndNode
is the closing >
IXmlTagEndTokenNode
token.
The Name
property is the identifier representing the name of the element being closed.
IXmlTagHeader
See also: IXmlAttributeContainer, IXmlIdentifier, IXmlToken, IXmlTreeNode
Represents the opening tag of an XML element. I.e. given the following XML:
The text <foo baz="quux">
will be an instance of IXmlTagHeader
. The StartNode
and EndNode
properties represent the <
and >
characters, and will be instances of the IXmlTagStartTokenNode
and IXmlTagEndTokenNode
marker interfaces.
The text <bar baz="quux" />
will also be an instance of IXmlTagHeader
, but will return an instance of IXmlTagEnd1TokenNode
to represent the closing />
. It will also return true
to the IsClosed
property.
The Name
property retrieves the IXmlIdentifier
token that represents the name of the tag. The text for the name can then be retrieved using Name.XmlName
and Name.XmlNamespace
properties.
Attributes are accessible via the inherited IXmlAttributeContainer
interface.
IXmlTagStart1TokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for the start token of a closing XML tag (</
).
IXmlTagStartTokenNode
See also: IXmlToken, IXmlTreeNode
Marker interface for the start token of an opening XML tag (</
).
IXmlToken
See also: IXmlTreeNode
Represents a token in the XML PSI tree. A token is a leaf node in the tree, and cannot be split into smaller nodes. It is the smallest building block node used when creating the tree. For example:
When parsed, this is split into the following tokens: <
, foo
, baz
, =
, "
, quux
, "
and />
. These tokens are then used to build higher level constructs in the PSI tree - a tag, with a start token, identifier, attributes (which themselves are composed of tokens) and a close tag token.
The GetTokenType
method returns the XmlTokenNodeType
of the particular token. It will be equal to one of the properties set on XmlTokenTypes
. Note that this method overrides and hides the ITokenNode.GetTokenType
method, however, the returned XmlTokenNodeType
derives from TokenNodeType
and also implements ITokenNodeType
. One useful method for the returned token type is to check if the node is a whitespace node - node.GetTokenType().IsWhitespace()
.
IXmlTreeNode
Root interface for all XML tree nodes, from tokens to other non-leaf nodes. The XmlTokenTypes
property retrieves the instance of XmlTokenTypes
used to construct the tree. This might be a derived instance in the cases that the XML dialect defines new constructs (e.g. XAML).
The AcceptVisitor
method implements the Visitor pattern. It will call the strongly typed Visit
method of the IXmlTreeVisitor
instance passed in.
IXmlValueToken
See also: IXmlToken, IXmlTreeNode
Represents a token that is a quoted value. Mostly used to represent the value in an attribute. The UnquotedValue
property provides the content of the token without the surrounding quotes, while the UnquotedValueRange
property provides the offsets to the unquoted value, relative to the start of the node.