XmlReader.Create Method (String)
Creates a new XmlReader instance with specified URI.
Assembly: System.Xml (in System.Xml.dll)
The inputUri parameter contains the URI to the XML file. This file must be located in the application's XAP resource, unless the XmlResolver has been changed to something other than XmlXapResolver. If you want to download the file from some other location, you must do the following:
Download the data. To do this, initiate an asynchronous request by using HttpWebRequest.
For a code example, see How to: Load an XML File from an Arbitrary URI Location with LINQ to XML.
An XmlReaderSettings object with default settings is used to create the reader. If you want to specify the features to support on the created reader, use the overload that takes an XmlReaderSettings object as one of its arguments, and pass in an XmlReaderSettings object with the correct settings.
The following example uses the Create method.
Dim output As StringBuilder = New StringBuilder() ' XmlXapResolver is the default resolver. Using reader As XmlReader = XmlReader.Create("book.xml") ' Moves the reader to the root element. reader.MoveToContent() reader.ReadToFollowing("book") ' Note that ReadInnerXml only returns the markup of the node's children ' so the book's attributes are not returned. output.AppendLine("Read the first book using ReadInnerXml...") output.AppendLine(reader.ReadInnerXml()) reader.ReadToFollowing("book") ' ReadOuterXml returns the markup for the current node and its children ' so the book's attributes are also returned. output.AppendLine("Read the second book using ReadOuterXml...") output.AppendLine(reader.ReadOuterXml()) End Using OutputTextBlock.Text = output.ToString()
The example uses bool.xml file as input.
<bookstore> <book genre='novel' ISBN='10-861003-324'> <title>The Handmaid's Tale</title> <price>19.95</price> </book> <book genre='novel' ISBN='1-861001-57-5'> <title>Pride And Prejudice</title> <price>24.95</price> </book> </bookstore>
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.