13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table 2-1: Public Properties of the XmlReader ClassPropertyPrefixQuoteCharReadStateValueXmlLangXmlSpaceDescriptionGets the namespace prefix associated with the currentnode.Gets the quotation mark character used to enclose thevalue of an attribute.Gets the state of the reader from the ReadStateenumeration.Gets the text value of the current node.Gets the xml:lang scope with<strong>in</strong> which the current noderesides.Gets the current xml:space scope from the XmlSpaceenumeration (Default, None, or Preserve).NoteWhen you read any sort of documentation about <strong>XML</strong>, you areusually bombarded by a storm of similar-look<strong>in</strong>g acronyms: URI,URL, and URN. Let's review these terms. A Uni<strong>for</strong>m ResourceIdentifier (URI) is a str<strong>in</strong>g that unequivocally identifies a resourceover the network. There are two types of URI: Uni<strong>for</strong>m ResourceLocator (URL) and Uni<strong>for</strong>m Resource Name (URN). A URL isspecified by the protocol prefix, the host name or IP address, theport (optional), and the path. A URN is simply a unique descriptivestr<strong>in</strong>g—<strong>for</strong> example, the human-readable <strong>for</strong>m of a CLSID (the 128-bit identifier of a COM object) is a URN.A bit mislead<strong>in</strong>g is the fact that URNs are often created us<strong>in</strong>g URLlikestr<strong>in</strong>gs. This regularly happens with <strong>XML</strong> namespaces, <strong>for</strong>example. The reason <strong>for</strong> this practice is that a URL has a highlikelihood of be<strong>in</strong>g unique, especially if you use a path with<strong>in</strong> yourcompany's Web site.An <strong>XML</strong> reader can pass through several different states. All the possible states aredef<strong>in</strong>ed by the ReadState enumeration and are listed <strong>in</strong> Table 2-2. The ReadStateproperty conta<strong>in</strong>s a ReadState enumeration value and is expected to return the currentstate of the reader, but actual implementations of a reader class must ensure that theproperty always holds the correct value.Table 2-2: Reader StatesStateDescriptionClosedThe reader is closed.EndOfFileThe end of the file has been reached successfully, butthe reader is not yet closed.ErrorA critical error occurred, and the read operation can'tcont<strong>in</strong>ue.InitialThe reader is <strong>in</strong> its <strong>in</strong>itial position, wait<strong>in</strong>g <strong>for</strong> the Readmethod to be called <strong>for</strong> the first time.InteractiveThe reader is open and functional.23

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!