XmlSyntaxTree Class

An XML document read from source text, together with what is wrong with it.

public sealed class XmlSyntaxTree : SyntaxTree

Example

var tree = XmlSyntaxTree.ParseText("<root />");
var updated = tree.WithChanges(new TextChange(new TextSpan(0, 0), "<!--generated-->"));
Assert.Equal("<!--generated--><root />", updated.GetText().Text);
Inheritance
SyntaxTree XmlSyntaxTree

Properties

NameDescription
FilePath
public override string? FilePath { get; }

Property value

string?

No documentation is available.

Methods

NameDescription
GetDiagnostics()Gets everything wrong with the document, in the order it appears in the text.
GetRoot()Gets the document this tree holds.
GetText()
IsEquivalentTo(XmlSyntaxTree?)Determines whether the two trees say the same thing, ignoring how they are laid out.
ParseText(SourceText)
ParseText(string)
WithChanges(TextChange[])
WithChanges(IEnumerable<TextChange>)

GetDiagnostics()

XmlSyntaxTree.cs

Gets everything wrong with the document, in the order it appears in the text.

public override IReadOnlyList<Diagnostic> GetDiagnostics()

Gets the document this tree holds.

public XmlDocumentSyntax GetRoot()
public override SourceText GetText()

Returns

SourceText

No documentation is available.

IsEquivalentTo(XmlSyntaxTree?)

XmlSyntaxTree.cs

Determines whether the two trees say the same thing, ignoring how they are laid out.

public bool IsEquivalentTo(XmlSyntaxTree? other)

Parameters

other XmlSyntaxTree?

Returns

bool

Remarks

This compares the documents rather than their trees, because two documents that differ only in whitespace between tags have genuinely different trees: that whitespace is character data, not trivia.

ParseText overloads

ParseText(SourceText)

XmlSyntaxTree.cs
public static XmlSyntaxTree ParseText(SourceText text)
Parameters
text SourceText
Returns

XmlSyntaxTree

Exceptions
ArgumentNullException
text is null.

ParseText(string)

XmlSyntaxTree.cs
public static XmlSyntaxTree ParseText(string text)
Parameters
text string
Returns

XmlSyntaxTree

Exceptions
ArgumentNullException
text is null.

WithChanges overloads

WithChanges(TextChange[])

XmlSyntaxTree.cs
public XmlSyntaxTree WithChanges(params TextChange[] changes)
Parameters
changes TextChange[]
Returns

XmlSyntaxTree

Exceptions
ArgumentNullException
changes is null.

WithChanges(IEnumerable<TextChange>)

XmlSyntaxTree.cs
public XmlSyntaxTree WithChanges(IEnumerable<TextChange> changes)
Parameters
changes IEnumerable<TextChange>
Returns

XmlSyntaxTree

Exceptions
ArgumentNullException
changes is null.