tailieunhanh - Professional ASP.NET 1.0 Special Edition- P20
Professional Special Edition- P20:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | or DTD. However things are different when using the .NET classes. Loading a combined schema or DTD and the XML data content that is an inline schema or an XML document that references an external schema or DTD into any of the XML storage objects such as XmlDocument XmlDataDocument and XPathDocument does not automatically validate that document. And there is no property that we can set to make it do this. Instead we load the document via an XmlTextReader object to which we have attached an XmlValidatingReader. The Load method of the XmlDocument and XmlDataDocument objects can accept an XmlValidatingReader as the single parameter instead of a file path and name. Meanwhile the constructor for the XPathDocument object can accept an XmlValdiatingReader as the single parameter. So all we have to do is set up our XmlValidatingReader and XmlTextReader combination and then pass this to the Load method or the constructor function depending on which document object we re creating . The document will then be validated as it is loaded create XmlTextReader load XML document and create Validator objXTReader New XmlTextReader strXMLPath Dim objValidator As New XmlValidatingReader objXTReader use the validator reader combination to create XPathDocument object Dim objXPathDoc As New XPathDocument objValidator use the validator reader combination to create XmlDocument object Dim objXmlDoc As New XmlDocument objValidator The XmlValidatingReader can also be used to validate XML held in a String. So we can validate XML that s already loaded into an object or application by simply extracting it as a String object using the GetXml method with a DataSet object or the OuterXml property to get a document fragment for example and applying the XmlValidatingReader to this. Validating XML in a DataSet Object Like the XML document objects a DataSet does not automatically validate XML that you provide for the ReadXml .
đang nạp các trang xem trước