Saxon API for .NET |

# DocumentBuilder.Build Method (XmlReader)

Load an XML document, delivered using an XmlReader.

public XdmNode Build(
XmlReader reader
);

#### Parameters

reader
  The XMLReader that supplies the parsed XML source

#### Return Value

An `XdmNode`, the document node at the root of the tree of the resulting in-memory document

#### Remarks

The XmlReader is responsible for parsing the document; this method builds a tree representation of the document (in an internal Saxon format) and returns its document node. The XmlReader is not required to perform validation but it must expand any entity references. Saxon uses the properties of the `XmlReader` as supplied.

Use of a plain `XmlTextReader` is discouraged, because it does not expand entity references. This should only be used if you know in advance that the document will contain no entity references (or perhaps if your query or stylesheet is not interested in the content of text and attribute nodes). Instead, with .NET 1.1 use an `XmlValidatingReader` (with `ValidationType` set to `None`). The constructor for `XmlValidatingReader` is obsolete in .NET 2.0, but the same effect can be achieved by using the `Create` method of `XmlReader` with appropriate `XmlReaderSettings`

Conformance with the W3C specifications requires that the `Normalization` property of an `XmlTextReader` should be set to `true`. However, Saxon does not insist on this.

If the `XmlReader` performs schema validation, Saxon will ignore any resulting type information. Type information can only be obtained by using Saxon's own schema validator, which will be run if the `SchemaValidationMode` property is set to `Strict` or `Lax`

Note that the Microsoft `System.Xml` parser does not report whether attributes are defined in the DTD as being of type `ID` and `IDREF`. This is true whether or not DTD-based validation is enabled. This means that such attributes are not accessible to the `id()` and `idref()` functions.

#### See Also

DocumentBuilder Class | Saxon.Api Namespace | DocumentBuilder.Build Overload List