.NET XML KB Articles
HOWTO
Modify an XML Schema by Using System.Xml.Schema Classes in Visual Basic .NET KB: 317903 |
This step-by-step article shows how to modify an existing XML schema.
The System.Xml.Schema namespace contains the XML classes that provide standards-based support for XML schema definition language (XSD) schemas.
The XmlSchema class contains the definition of a schema. All XSD elements are children of the schema element; this represents the World Wide Web Consortium (W3C) schema element. You can use these classes to generate new XML schemas or modify existing ones.
|
Use MSXML 4.0 with COM Interop in Visual C# .NET KB: 317750 |
This step-by-step article demonstrates how to use Microsoft XML Core Services 4.0 (MSXML) in Visual C# .NET projects by using the COM interoperability features of .NET. The Microsoft .NET Framework provides ways to interoperate with the existing COM components. Because MSXML 4.0 is COM-based, when you use MSXML with the .NET applications, MSXML runs as unmanaged code outside of the common language runtime (CLR).
|
Use MSXML 4.0 with COM Interop in Visual Basic .NET KB: 317728 |
This step-by-step article demonstrates how to use Microsoft XML Core Services 4.0 (MSXML) in Visual Basic .NET projects by using the COM interoperability features of .NET.
The Microsoft .NET Framework provides ways to interoperate with the existing COM components. Because MSXML 4.0 is COM-based, when you use MSXML with the .NET applications, MSXML runs as unmanaged code outside the common language runtime (CLR).
Applications that you develop solely with System.Xml provide numerous benefits, such as interoperability with ADO.NET components, scalability, and other enhancements that System.Xml and the .NET Framework offer. However, you may want to use MSXML 4.0 in .NET to do the following:
- Port the existing code with minimal changes and use the current skillset.
- Work with an existing code base that uses Simple API for XML (SAX) or msxsl:script elements (with older scripting languages) in
- Extensible Stylesheet Language Transformations (XSLT).
NOTE: System.Xml supports scripting with the CLR compliant languages.
Interoperate with MSXML 3.0 to use the older XSL stylesheet standard. Overcome the XSLT performance issue with the System.Xml.XslTransform class.
|
Create a Key Element for an XML Schema KB: 317688 |
Use this step-by-step guide to programmatically add a key element to an existing Extensible Markup Language (XML) schema.
With relational data representation, you can create a primary key or a unique key to identify a single instance of data or a row. A key element is necessary to achieve a similar, unique representation of data in hierarchical data. XML data representation is an example of hierarchical data representation. In an XML schema, a key element makes the data representation unique. The XmlSchemaKey class identifies a key constraint and represents the World Wide Web Consortium (W3C) key element.
The XmlSchema object contains the definition of a schema. All XML Schema Definition Language (XSD) elements are children of the schema element. XmlSchema represents the World Wide Web Consortium schema element.
|
Modify XML Data by Using DOM in .NET Framework with Visual C# .NET KB: 317666 |
This step-by-step article describes how to use the System.Xml.XmlDocument class and the related classes to programmatically modify XML documents.
XML content can be classified broadly into a collection of nodes and attributes of the nodes. You can modify the content by modifying the nodes or the attributes. The System.Xml.XmlDocument class implements the core XML Document Object Model (DOM) parser of the Microsoft .NET Framework. This class is compliant with the World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 and Level 2 Core standards. You can use the DOM model implementation to modify the content of XML documents; for example, you can insert, update, or delete data.
|
Modify XML Data by Using DOM in .NET Framework with Visual Basic .NET KB: 317665 |
This step-by-step article describes how to use the System.Xml.XmlDocument class and the related classes to programmatically modify Extensible Markup Language (XML) documents.
XML content can be classified broadly into a collection of nodes and attributes of the nodes. You can modify the content by modifying the nodes or attributes. The System.Xml.XmlDocument class implements the core XML DOM parser of the .NET Framework. This class is compliant with the World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 and Level 2 Core standards. You can use the DOM model implementation to modify the content of XML documents; for example, you can insert, update, or delete data.
|
Access XML Data Using DOM in .NET Framework with Visual C# .NET KB: 317664 |
This step-by-step article explains how to access required data in extensible markup language (XML) documents programmatically by using the System.Xml.XmlDocument class and the related classes.
The System.Xml.XmlDocument class implements the core XML Document Object Model (DOM) parser of the .NET Framework. The System.Xml.XmlDocument class is compliant with the World Wide Web Consortium (W3C) DOM Level 1 and Level 2 Core standards.
XML content can be classified broadly into a collection of nodes and attributes of those nodes. You can use the DOM model implementation of System.Xml to query or to access these nodes and attributes of XML documents. The DOM implmentation of System.Xml provides several ways to access these nodes and the attributes.
|
Access XML Data Using DOM in .NET Framework with Visual Basic .NET KB: 317663 |
This step-by-step article explains how to access required data in extensible markup language (XML) documents programmatically by using the System.Xml.XmlDocument class and the related classes.
The System.Xml.XmlDocument class implements the core XML Document Object Model (DOM) parser of the .NET Framework. The System.Xml.XmlDocument class is compliant with the World Wide Web Consortium (W3C) DOM Level 1 and Level 2 Core standards.
XML content can be classified broadly into a collection of nodes and attributes of those nodes. You can use the DOM model implementation of System.Xml to query or to access these nodes and attributes of XML documents. The DOM implmentation of System.Xml provides several ways to access these nodes and the attributes.
|
Load and Save XML by Using DOM in .NET Framework with Visual C# .NET KB: 317662 |
Use this step-by-step guide to learn how to programmatically load and save Extensible Markup Language (XML) documents by using the System.Xml.XmlDocument class. This class is compliant with the World Wide Web Consortium Document Object Model (DOM) Level 1 and Level 2 core standards. Furthermore, System.Xml.XmlDocument implements the core XML DOM parser in Microsoft .NET Framework.
XmlDocument is derived from System.Xml.XmlNode class, so it inherits several properties and methods from the XmlNode class.
|
Load and Save XML by Using DOM in .NET Framework with Visual Basic .NET KB: 317661 |
Use this step-by-step guide to learn how to programmatically load and save Extensible Markup Language (XML) documents by using the System.Xml.XmlDocument class. This class is compliant with the World Wide Web Consortium Document Object Model (DOM) Level 1 and Level 2 core standards. Furthermore, System.Xml.XmlDocument implements the core XML DOM parser in Microsoft .NET Framework.
XmlDocument is derived from the System.Xml.XmlNode class, so it inherits several properties and methods from the XmlNode class.
|
Populate a TreeView Control with XML Data in Visual C# .NET KB: 317597 |
This step-by step article describes how to populate a TreeView control by using Extensible Markup Language (XML) data in Visual C# .NET. Because both XML and the TreeView control represent the data in a hierarchical format, the TreeView control is a natural choice to display XML data. The TreeView control has a Nodes collection with root TreeNode objects. Each TreeNode in turn has its own Nodes collection that holds more than one child TreeNode. NOTE: This sample uses the Document Object Model (DOM) parsing classes of .NET to process XML.
|
Validate an XML Document by Using Multiple Schemas in Visual Basic .NET KB: 317595 |
This step-by-step article describes how to use the XmlValidatingReader object to validate an Extensible Markup Language (XML) file with multiple XML Schema Definition Language (XSD) schemas. The code sample uses the XmlSchemaCollection object to cache the schemas. For more information about the XmlValidatingReader and the XmlSchemaCollection classes, see the REFERENCES section.
If the namespace is already associated with another schema in the collection, the schema that you add replaces the original schema in the collection. For example, the following code removes the Authors.xsd file from the collection and adds the Names.xsd file to the collection:
schemaColl.Add("urn:author", "authors.xsd");
schemaColl.Add("urn:author", "names.xsd");
The XML file is always validated against the last schema.
|
Validate XML Fragments Against an XML Schema in Visual Basic .NET KB: 317463 |
This step-by-step article describes how to use XmlValidatingReader and XMLSchemaCollection objects to validate an Extensible Markup Language (XML) fragment against an XML schema.
XmlValidatingReader implements the XmlReader class and provides support for XML data validation. The Schemas property of XmlValidatingReader connects the reader to the schema files cached in an XmlSchemaCollection. The ValidationType property of XmlValidatingReader specifies the type of validation the reader should perform. If you set the property to ValidationType.None, you create a nonvalidating reader.
You can only add XML Schema Definition Language (XSD) schemas and XML-Data Reduced (XDR) schemas to XmlSchemaCollection. Use the Add method with a namespace URI to load schemas. For XML schemas, the typical namespace URI is the targetNamespace property of the schema.
|
Use the Encoding Property with System.Xml Classes in Visual Basic .NET KB: 317169 |
This step-by-step article explains how to use the Encoding property with XML in .NET Framework. The encoding declaration in the XML declaration identifies the encoding format of the XML data. In the System.Xml namespace, the Encoding property of the classes identifies the encoding format.
The System.Xml namespace in .NET Framework includes the following classes that have the Encoding property:
- XmlDeclaration: represents XML declaration node
- XmlParserContext: provides the context information required by the XML reader classes to parse an XML fragment
- XmlTextReader: pull model parser; provides forward-only, fast, non-cached access to XML data
- XmlValidatingReader: validates XML documents against XSD, XDR, or DTD
The Encoding property is a case insensitive string such as "UTF-8" or "ISO-8859-1" with the XmlDeclaration class. With the other classes, the Encoding property is of the type System.Text.Encoding class.
|
Use the XPathException Class in Visual Basic .NET KB: 317108 |
This step-by-step article demonstrates how to write exception handling code to trap and handle an XPathException (System.Xml.XPath.XPathException). Writing error handling code to catch an XPathException when executing the Select and Compile methods of the XPathNavigator object will help to identify exceptions caused by an invalid XPath query expression.
|
|
|