1. ������� �����
1.1. ����������� XML.NET
1.2. Microsoft .NET XML ������

1. ������� �����

��������� .NET Framework ���������� XML Document Object Model (DOM), ����� ���������� ������ � ������ � XML ���������� � �������������� ������ ��� ������, ������ � ��������� � �������� XML ���������. ��� ������ �������������� ������������� ��� System.XML, ������� ����� ���������� XML DOM � ���������� ������� � ������ ���������� ADO.NET. XMLDataDocument �������� ����� �� ���������� DOM � ��������� ������������ ���, � ������������ ������ � ����������� ������. XMLDataDocument ���������� XML �� ����������� ������ � ADO.NET DataSet. ��������� .NET-based ���������� ��������� ����� ������������ ����������� ������ � ������������ ��� System.XML ��� ���������� � ��������� � ���������� XML � ������������ ������� � DataDocument. ���� �������� ������������ ������������ ����������� n-tiered ��� ����� � ������������� ������.

Microsoft .NET XML � �������� ADO.NET ���������� ������ ������ ���������������� ��� ������� � XML ������ (�����, �������������� ���������������� ������ ������) � ����������� ������ (�������, ��������� �� ����� � ��������). XML Framework ������ XML ������ �� ������ ������ ������ � ���� ������ DOM, ���� � ������ ����� ���������� ����������� ����, � �� ����� ��� ADO.NET Framework ������������ ���������� � ��������� � ����������� ������ � �������� ������� DataSet.
���� ��� �������� ���������� ��� ������� � ������ � XML Framework � ADO.NET:

- DataSet, �������������� �������� ����������� ������ � ADO.NET Framework.;
- XMLDocument, ������������ DOM � XML Framework.
- XMLDataDocument, ������������ ADO.NET � XML Framework � �������������� ����������� ������ �� DataSet, � �����, ���������������� �� � ������� XML ���������.

XMLDataDocument �������� ���������� XMLDocument. .NET-���������� ����� ������������ XMLDataDocument ��� �������� XML ��� ����������� ������ � ��������� ���, ��������� DOM. ����� XMLDataDocument ��������� ����������� ������, ���������� ������������� ������ ����� DataSet � DOM. ����� ����, ��� XMLDataDocument �������� ����������� ������, ���������� ����� ���������� � ��� ����������� ����, � ������� .NET XML Framework API.
������, ������� �������� XML � ADO.NET Framework, ��������� ���������� ��� ����� ���������:

�������� ������
������ � ����������� ������ � ������� ADO.NET - ��������, � ������������� DataSet ��� ��������� � ����������� ������ ��� ������������� XML.
- ������, � ������ XML ������ �/�� DataSet ��� ������������� XmlDataDocument (����� ���������� XML, �� ��������������� ������������ �������������, ����� ��������.)
������ � XML ���������� - �������� � ������������� XmlDocument ��� ��������� � ������� XML ������.
- ������������� ����������������� ������ � XmlDataDocument ��� ������, �����, ��������, ��������� � ������ ����������� ���������. ��� �������� ���������� XmlDocument.
������ � ����������� ������ � XML ���������� (XML � ADO.NET) - �����������������, ����������� ������ � XmlDataDocument ������ � DataSet.
- �������� DataSet �� XmlDataDocument, � ������� ������������ ������������� � ������� ������������������ �������� XML ���������.
- ������ � XML �������������� ����������� ������ � DataSet.
- ��������� ����������� � ���������� �� XML ��������� ��� ����������, ������������� ������. ��������, �� ������ ������������� � ���������� ����������� ������ ��� ����������� �� �������� XML ���������, ��������� XSLT (Extensible Stylesheet Language Transformations) � ����������� ������. ���������� XPath �������� � ����������� ������.

1.1. ����������� XML.NET

������ XML.NET � ������������ ��� System.XML ������������� ��� ����, ����� ���������� �������������� ���, ��� ����������������� �� ���� �������:

����������� ����� XmlReader ������������ ������ ��� ����������� �������, �� ���������� �������� ������ ������� � XML ������. ����������� ����� XmlWriter ������������ �������, �� ������������, ���������������� ���� �������� XML �������, ���������� XML ���������, ������� ������������� ������������ W3C Extensible Markup Language (XML) 1.0 � ������������ ��� �� ������������ XML. XmlTextWriter � XmlTextReader - ��������������� ��� ����������������� ���������� ������ � ������������ ��� System.Xml.
����� XmlDocument ������������ �������������� ������� (http://www.w3.org/TR/DOM-Level-1/) � ������� (http://www.w3.org/TR/DOM-Level-2/) ������� ������������ W3C XML Document Object Model (DOM).
XmlNodeReader ������������ XmlReader API � ������������ ���� DOM. �� ���������� ����� ����, ������� ������� � ������ DOM, ������� ���� - ������ �� �������. XmlElement ������������ ������� � ������ DOM. XmlAttribute ������������ ������� ������� XmlElement.
����� XmlTransform ������������ WC3 �������������� � �������� ������������ XSL (XSLT) (http://www.w3.org/TR/XSLT), ������� ��������� ������������� ���� XML �������� � ������. �� ���������� XmlWriter ��� XmlReader, ����� ���������� ������ ��� ������ ���������������� XML ���������.
����� XmlNavigator ���������� ��������� ��� �������������� ������ ������� �� XML ���������. �� ������������ ���������� � ��������� ��� WC3 XML Path Language (XPath) ��������� (http://www.w3.org/TR/XPath) � ������������ XslTransform.
����������� ����� XmlResolver ��������� ������� XML �������, ���������� Uniform Resource Identifier (URI - ��������������� ������������� �������). XmlResolver ������������ XmlTextReader ��� �������� ������� DTD �������� � ����. �����, �� ������������ XslTransform ��� ��������� ��������� <xsl:include>. XmlUrlResolver - ���������� ���������� XmlResolver ��� URL.
����������� ����� XmlNameTable ������������ ������� ����������� ��������� ��������. �� ������������ ����������� �������� ��� ��������������� ����������� XML, ������� ��������� ������������ ��� �� ����� ������-������ ��� ��������� ��������� � ��� ��������� � XML ���������. ���������� ��������� ����� ������������ ������ XmlNameTable ��� ��� ����������� ���������� ������ XmlNameTable � ����� ��������� �������������.

1.2. Microsoft .NET XML ������

�������������� ���� ������ ���������.NET Framework ������������ ��������� Xml ���������� � ������������� ������ API ��� ������� � Xml ����������. �������������� ��������� ����������� ���, ����� ������, XSL ����, XSL ��������, ���������� ����������, � ��������� �� ����������.

����� ��������
XmlDataDocument ������������ ����������� XmlDocument, ������� ����� ���� ������ � �������� ADO.NET DataSet. �� ������ ������������ ������������� � ��������� ����������������� XML ����� ����������� ������������� DataSet ��� ������������� DOM XmlDataDocument.
XmlNavigator (abstract) ������ � ������ Xml ������ � �������������� ������ �������. ������������ Xpath, �������������� ��� XmlDocument. ��� ����������� �����.
DocumentNavigator ������������ cursor-style ������, ��� ���������� memory-resident ������� Xml � ������������ XPath ���������. �����, ������������� XmlNavigator ��� DOM.
DataDocumentNavigator ������ � ������ ����������� ������ � �������������� ������ �������. ������������ ��������� Xpath ��� XmlDataDocument. ������������� XmlNavigator �� XmlDataDocument.
XmlResolver (abstract) ���������� ������� Xml �������, ���������� Uniform Resource Identifier (URI). ��� ����������� �����.
XmlUrlResolver ���������� ������� Xml �������, ���������� URI. ������������ XmlResolver ��� URL.
XmlSchemaCollection �������� ����� �� ������������ ��� URI. ������ ������������ ��� ����� ����� ��������� ����������� ��� ������, ��������������� XML-Data Schema ��� W3C Xml Schema. XmlSchemaCollection ����� ��������� XSD � XDR �����, � ������������� �� �� ���������� "cooked schema representation". ����� ����� Validate() ���������� ��� ���������� ������������� ��� ����������� �������� ������������ (� ������: run-time) ������ ��������� ���������.
XmlReader (abstract) ������������ �������� ������, ������� ������������ �������, non-cached, forward-only ����� ������� � Xml ������. ���� �������� ������ ����� ������ ����� ��� �������� Xml. ��� ����������� �����.
XmlTextReader ������������ �������, non-cached, forward-only ����� ������ � Xml ������. ������������ XmlReader ��� ��������� ������.
XmlWriter (abstract) ������������ �������, non-cached, forward-only ��������� ��������� ����������� Xml �������. ���� �������� ������ ������������ ��� ������ � ����� ��� ��������. ��� ����������� �����.
XmlTextWriter ������������ �������, non-cached, forward-only ��������� Xml �������, ���������� Xml ���������, ������� ������������� ������������ W3C Xml 1.0 � ������������ ��� � ������������ Xml. ���������� XmlWriter.
XmlNameTable (abstract) �������, ������������ ������, �����������, ��� �������������� ����������� �������� ��� ��������������� ����������� Xml, � ��� ������������ ���� � ��� �� ������ ������ ��� ������� �������������� �������� � ���� �������� � Xml ���������.
XmlNodeReader ������������ �������� ������, ������� ������������ �������, non-cached �������� ������ ������� � Xml ������ � XmlDocument ��� � ������������ XmlNode � ������ XmlDocument.
XslTransform ��������������� Xml ������, ��������� XSL ������� ������.
XmlConvert �������� � ���������� ����� � Xml, ������� �������� ������������ ������� (�����, ��� ������� ��� ������������ ������� Katakana) ��� ���������� ��� ����������� Xml ��� ��� ��������� ��� ������������� ����.
XmlException ���������� ���������������� ���������� � ��������� ������ ��������������� �������, �������: ����� ������, ����� ������, ���������� �������, � ��������� ��������.

2. ������ � ������ Xml
2.1. ������ Xml � ������� XmlTextReader
 2.1.1. �������� ������������ ����� ������ � ������� XmlTextReader
 2.1.2. ������ ������������ Pull-������ ������ Xml?
 2.1.3. ��������� ������������ ���������� ������������ � XmlTextReader
 2.1.4. �������������� ������� XmlTextReader
 2.1.5. ������� ��������� ��������� ��� XmlTextReader
2.2. ������ Xml ���������� XmlTextWriter
 2.2.1. ��� XmlTextWriter ���������� ������ �������������� (Well Formed) XML
 2.2.2. ������ � �������������� ��� ���������� XmlTextWriter

2. ������ � ������ Xml

����������� ������ System.Xml �������������� ��������� XmlReader � XmlWriter, ������� ������������ ������ � ������ XML. XmlReader ������������ �������, non-cached �������� ������������� ������ ������� ������� � XML ������. XmlWriter ������������ �������, non-cached, forward-only ���� ��������� XML �������, ���������� XML ���������, ������� ������������� ������������ W3C Extensible Markup Language (XML) 1.0 � ������������ ��� ������������ XML. XmlTextReader � XmlTextWriter - ���������� ���������� XmlReader � XmlWriter � ������������ ��� System.Xml.

2.1. ������ Xml � ������� XmlTextReader

����� XmlTextReader �������� XML ������ (��������� �������� forward-only) �� ������� �����, ������� TextReader ����� ��� URL (������� �������������� Web ���� ��� ��������� ����).
XmlTextReader ����� ��������� ������ � ��������:

� ������ Xml ��������, ����� ���������� �������� ���������, ��� � ������ ���������� Xml �����.
� ������ Xml ��������, ��������� �� ���� �������� (��������, �������� ����� �� �������� ������ ��������� ���������).
� ������ �������������� ��������� Xml ������, ���������� �� ���� ������ ���� ���������. ��������, ���� ������ �������������� ������, ������� ������: 16/32/64 ������ ����� �����, �������, boolean, ����, ������, � ������ ����.
� ������ ������� ����.
� ����������� �� �������� ������ ��� ������.
� ���� ���������, ������������ ���, � �������.
� ���������� ���� � DTD �������� ������������ �����.

2.1.1. �������� ������������ ����� ������ � ������� XmlTextReader

�������� ������������ ����� ������ ����������� � ������� ��������������� ������� XDR ��� XSD ����, � ����� ��� DTD. ���� ��� ��������, ������������ XmlUrlResolver, ����� ��������� ������� DTD ��� �����, ������� ��������� ��� ����� ��������.
DTD ��� ����� ����� ���������� �������� �� ��������� ��� ���������. ��������:

<!ATTLIST e a CDATA "123">

���� ������� "a" � �������� "e" �� ��������� � Xml ������, �� ��� ����� ���� �������� �� ��������� "123". �������� �� ��������� �������� ������������ ��� ��, ��� � ������� �������� � ��� ��������, ��� ���������� �������� �� ��������� ������� ��������� "true" �� �������� IsDefault.

2.1.2. ������ ������������ Pull-������ ������ Xml?

XmlReader ���������� "pull" ������ ��� ������ XML. "Pull" ������������ "Simple API for XML" (SAX) ��� event-driven ������, ������� ����� �������� �������� �������� � ����������.
�������������� ����������, ������������ push-������, ��������� ������� ���������� ���������, ������������ ������������ ���������, �������, ����������� � ��� �����. ���� �������������� ���������� ���������� pull-������, ���������� ��������� ���������� ���� ��������� ������, ���������� ������ ������. Pull-������ ������������ ��������� ������������:

�������������� ��������
���������� ���������� ���������� (Simplified state management) ���������� �������� Push-model ������ ��������� ����� ������� ��������� ������ ���������, ������� ��� ������������� Pull-model ����� ����������, �� ���� ���������� ���������� ������������, ������ ����, ���� ���������� ��������.
������������� ������� ������ (Multiple input streams) Pull-model ������������� ����������� ������������ ��������� ������ ������������� ������� ������. ���������� ����� � Push-model ����� ����������.
���� �������������� ������������� (Layering test) Push-model ����� ����������� �������������� ������������ Pull-model, �� �� ��������.
��������� ������� (Hints from client) ����� ���� ���������� ����� Pull-model API, ������� ����������� ����������� ������������ ������ ��������� ��������������� ����������� � ���, ��� ��� ������� �� ��������� ����, � ������ ����������� ��������������� ����������� �������������� ��� ���. ����� ���� ��������� ��������� ����� ������ �����, ����� ������������ �����, ��������, ��� ��������� ������ �������� ����� ������, �������������� ���������� ������ ������������� ����� ����� �� ��� ������, ������ ����������� ������, ������� ������������ ����� ���������, ��� �������� �������� ���������� ���������� ��������� (��������� ������).
�������������� ��������� �������������� ����� (Avoids extra copy) Pull-model ���� ����������� ������������ ���������� �������������� ���������� ������� ��� ������ �����. ��� ��������� �������� �������������� ����� �� ������ ��������������� ����������� � ������ ������, ������� �����, � ���� ������, ������� � ����� ������������.
��������� ���-���� (Skipping things) Push-model ������ ���������� �� ������ ������ ��, ��� �� ����� �� ���������, ������� ��� ��������, �����������, �����, ������������� ������������, � �.�. � Pull-model, ������������ ���������� ������ ��, ��� ���������. ���� ������������, ��������, �� ������ ��������, �� �������� ������� �� ������ ���� ����������� ��������, ���������� ����������, ������������ �������������. ��� ��������� ������� ������ ����������� ���������� ��������� ������ �������� Xml ���������.

2.1.3. ��������� ������������ ���������� ������������ � XmlTextReader

���������, �� ����������� ������������ (�������, ������� ���������, ����� � ������ ������) ����� ���������� ���������������� ����� ���������:
- �����������, �� ����������� ������������ - ����� �� ����������� ������������, ������� ������ ���� ��������� � �������� ���������.
- �� ��������, �� ����������� ������������ - ������������� ������������, �� �������������� ��� ���������� � �������� ��������� (�����, ���������� ��� ��������� ���������������).

��������� ���� ������ ������������ �����������, �� ����������� ������������ ��� ��������� (*), � �� ��������, �� ����������� ������������ ��� ����� (.), ��� �� ������������������ �� �������. ������� newline ����� �������������� �������������� ��� ��������� ��� �����.

<!DOCTYPE test [
<!ELEMENT test (item|bar)*>   <-- element content model -->
<!ELEMENT item (item*)>   <-- element content model -->
<!ATTLIST item xml:space (default|preserve) #IMPLIED>
<!ELEMENT bar (#PCDATA|b|i)*>   <-- mixed content model -->
<!ELEMENT b (#PCDATA)>   <-- mixed content model -->
<!ELEMENT i (#PCDATA)>   <-- mixed content model -->
]>.
<test>.
....<item>.
........<item xml:space="preserve">*
************<item/>*
********</item>.
....</item>.
....<bar>*
********<b>This<b>*
********<i>is</i>*
********<b>a test</b>*
****</bar>.
</test>.

�����������, �� ����������� ������������ ������������, ��� ��� ���� "SignificantWhitespace", �������� �� ��������, ��� �� ��������, ������������� ������������ ������������ ������, ��� "Whitespace". ��� ��������� �������������� ����������, ��. ������ � 2.10 � ������������ W3C Extensible Markup Language (Xml) 1.0 (http://www.w3.org/TR/1998/REC-xml-19980210#sec-white-space).

2.1.4. �������������� ������� XmlTextReader

�������������� ���� ������� ����������, ��� ��������� ������������� �������� ����� �������� �� ���������� �������� ������. ������������ ��������, ������� �� ����� ���� ��������������� ����� ������ �������� ������, ��� �������� Namespace (������������ ���). XmlReader ���������� ���, ����� �� ��������� ����������� �� ������������� �������, � ��� �� �� ���� ������� ������������ ����� ����������. �� ��������� ���������� ���������� ��������� �������, ������� ����� ����� ������������� ����� ���������� �����������. ��������, ���� Validation (�������� ������������) ����������� � 'Auto' � Entity handling (��������� ��������) ����������� � 'Ignore', � ��������� ���� ���������������, ��� �������� �� �����������. ��� ������ ��������, ��� �������� ������ ����� ������������ �������� ����� ���������, �� ��������� ��� � �.�., �� ������, ���������� �������� ������������, �� �� ���� ����������.

�������� ����������� ��������� ��������
����� �������� ������
����� ��� �������� ����� ������
Whitespace �� ����� ��������� �������� ������
Validation �� ����� ��������� �������� ������
EntityHandling �� ����� ��������� �������� ������
Normalization �� ����� ��������� �������� ������
Namespaces ��� ��� ������.
XmlResolver �� ���������� ����� ��������� �������� ������

���� EntityHandling ����������� � 'IgnoreEntites', � Normalization ����������� � 'true', �� ��������� EntityHandling ����� ��������� ������������ ��������� ������� �������. �������� ������� ������� ������� �� ������������, ���� EntityHandling - 'IgnoreEntites'.

2.1.5. ������� ��������� ��������� ��� XmlTextReader

�������������� ���� ������� ����������, ��� ��������� �������� XmlTextReader ����� �������������� ��� ���������� ��������� ���������.

�������� Validation Callback URIResolver Normalization
����� ������� - �� ��������� ����������� ����� None null null false
��������������� W3C
(������ ����������)1
None �� �������� null true
��������������� W3C
(���������� � �������)2
None �� �������� �������� ��������� � ��� ������� �������� ������ ���� �������� true
��������������� � �������������
� DTD Auto ��� DTD
�� �������� 3 �������� ��������� � ��� ������� �������� ������ ���� �������� true  
������ �������������� � ���������� �������� ������������ ����� Auto (� �� DTD) ��� Schema �� �������� 3 �������� ��������� � ��� ������� �������� ������ ���� �������� true

1. ������������ �������� �� ��������� �������� � ��������, �� ������ �� ����������� ������������, �� �������� ������� ������� ��������.
2. ������������ �������� �� ��������� �������� � �������� �� ����������� ������������, � ����� �� �������� DTD � ���������.
3. ���� ������������ �� ������� ��������, ��� ������ �������� ������������ ������������ ����� callback. ���� ������������ ������� ��������, ������ ������ �� ����������� �������� ������������ ����� � XmlException. ��� ���������� ��������� ������, ����� ���� �������������� ������ XmlTextReader ������ �� ������ ������������.

2.2. ������ Xml ���������� XmlTextWriter

����� XmlTextWriter ���������� ������, ������� ����� XML ������ non-cached � forward-only �������� � ������, ����� � ������� TextWriter. ����� XmlTextWriter ��������� ����������� ����� XmlWriter. ������ XmlWriter �������� ���������� XML ���������, ������� ������������� ������������ W3C Extensible Markup Language (http://www.w3.org/TR/1998/REC-xml-19980210) � ������������ ��� �� ������������ XML (http://www.w3.org/TR/REC-xml-names/).
XmlTextWriter ����� ��������� ������ � ��������:
- ������ ������������� ����������� Xml, ���-��: ���������� � ������ ������, ���� ���������, ������������� ����� ������ � ����� � ����������� ������������ ���, �����������, ��������, CDATA, ��������� ������, �������� � ������ ��������, ������ ������, �������������� - ������������� ����� (�������� ��� �������� �� ������������� ������ ��������� Xml).
- ��������� ������ �� 64-������ � ������������������ � ��������������� ESC �������.
- ���������� �������, ������� �������� ���������� � ��������� ������, ������ ������������� ���������� � ���� �������� �����, � ������� ��� �������� ������.
- �������� ������� ������� ������������ ���, ����, ��� �������� ������������ ���.
- ������ ���������� ���, ��������� ���, � �������� ������.
- ������ �������� ��� ������� � ������������� ������ ������, ��������, ������ ��������, ���� � �����, ���������� �����, ��������� � ������� �������� � ��������� �������, � 16-������, 32-������ ��� 64-������ ����� �����.
- ������ ����������� ����� � �����.
- ����������� ��������� ��� ��������������, �����������, ������������ ��� ����������� ����� ������ � �����.

2.2.1. ��� XmlTextWriter ���������� ������ �������������� (Well Formed) XML

����������, ����� ���������������� ������������� XmlTextWriter ��� ������ � ��������� well-formed XML ���������� � ����������� ������������ ������������ W3C Extensible Markup Language (XML) 1.0 (http://www.w3.org/TR/1998/REC-xml-19980210):
- ��� WriteAttribute, ���� ������������ ������� �������, XmlTextWriter ������� ������� ������� � ������ (��������) ���������� ������� &quot;. ���� ������������ ��������� �������, ��� ����� �������� �� �������� ������� &apos;.
- ��� WriteString, XmlTextWriter ��������� ����������� �������, ������� �� �� &amp; &lt; &gt; � �� �������� �������� ��������, ����� ��� ���������. ���� ������ ��������� � ��������� �������� �������, �� ����� ����� ���������� &apos; � &quot;. ���������� �������� 0x-0x1F ������������ ��� �������� ���� �� &#0; � �� &#x1f;, ����� �������� �������������� ������������ 0x9, 0x10 � 0x13.
- ��� WriteBase64, XmlTextWriter ��� �������� ��� base64 ��������, ��� �� ��� ����� ���� ��������� � �������������� ReadBinary ��� XmlReader.
- ��������� �������� ������������ ��� � ��������� ���������� xmlns (��. Namespace Handling by XmlTextWriter).
- �����������, ��� �������� xml �������� � ���������� �������. ��������, �� ��������� ������������� ������� ��� ��������, ����� CDATA ������ ��������, ��� ������������� ���������� �������� ���������. ����� �������������, ��� ���������� - �������� � ������ �������� xml:space ���������. ��������� ������ �����:
w.WriteAttribute("xml:space", "", "preserve");
���������� �������� - "default" � "preserve". ���� �������� - �� ��������� �� ���� �� ���� ��������, ArgumentException ����� �������.
- ������ �������� xml:lang ��������. ��������� ������ �� �����:
w.WriteAttribute("xml:lang", "", "U.S.A.");
� ���� ������ ArgumentException ����� �������, ������ ��� ��������. "U.S.A" �� ������������� BNF ��� ��������������� ����� ��� ���������� � IETF RFC 1766. BNF ������ ���� ���������:
Language-Tag = Primary-tag ( "-" Subtag )*
Primary-tag = 1*8ALPHA
Subtag = 1*8ALPHA
ALPHA = ����� ASCII ���������-�������� �������� � ���������� 65-90 � 97-122.
����� ��������������� ���� ��������� ����� � ���� ��� ������� ���������� ��������� �����, ���������� �������� "-", ��� ��������� ����� � ��������� ����� ����� ����� �� 1 �� 8 �������� ALPHA ASCII. ����������, �� ��� ��� ���� ������ � �������� ����� �����/�������� �� ����������. ����� ���������� ��� �����, �������������� ����� ��������, ����������� ����� System.Globalization.CultureInfo.
- ���� Close() ��� � ���������� ������������ xml ��������, InvalidOperationException ����� �������.

XmlWriter �� ��������� ���������:

- ������������ �������� � ����� ������� ��������.
- ������� Unicode, ������� �� ������������� ���������, �� ������������ ��� ���������� ��������.
- ����� ������� �� ����� ���� ����������.
- ������� � DOCTYPE pubid ��� sysid �� �����������.
- Newlines � �������� ������� ������������, ��� � &#A;, ��� ��� ��� ����������� � ������������ � ��������� � W3C ���������� �������, �������������� �������������� ����������, �� ������� XmlTextReader.

2.2.2. ������ � �������������� ��� ���������� XmlTextWriter

XmlTextWriter ������������ ���� ������������ ���, ��������������� ���� ������������� ���, ������������ ������� ������ ��������. ��������:

XmlTextWriter w = new XmlTextWriter(Console.Out);
w.WriteStartElement("root","urn:1");
w.WriteStartElement("item","urn:1");
w.WriteEndElement();
w.WriteEndElement();
w.Close();

� ���������� ������� ���������:

<root xmlns="urn:1"><item/></root>

�������� ��������, ��� ���������� ������������ ��� ��� ���������� �������� item �� ����������� ��������.

��������� ���������

���� ��������� ����������� ����� � ������������� ��� URI, �� ��� ������ ����� �������, ��������������� "Namespace Defaulting" (http://www.w3.org/TR/1999/REC-xml-names-19990114/defaulting) � ������������� ��� W3C ������������ Xml, ��� ������������� ���������� ����:

XmlTextWriter w = new XmlTextWriter(Console.Out);
w.WriteStartElement("root");
w.WriteAttribute("foo","urn:1", "123");
w.WriteEndElement();
w.Close();

� ���������� ������� ���������:

<root n1:foo="123" xmlns:n1="urn:1"/>

����������: ��� �����������, ���� ���� �������� ������� ������ � �������� �� ��������� ������������� ��� "URN:1". �������� ���������, ��� n{i}, ��� i ���������� � 1. ������ ����������� ��� ������� ���������� ��������, ��� ���, ���� ���������, ���������� ������� ����� ��������� � ��������������� ��������, "n1" ����� �������������� ��������. ����� ����������� �������� ������ ������������ ������������ Xml, ��������������� "W3C Canonical XML Version 1.0 specification". (http://www.w3.org/TR/sec-namespaces).

�������� ���������� ������������ ��� �������

�� ����� ������ �������� ��� ���������� ������������ ��� �������. ��� �������, ���� �� ������, ��� ����� �������������� ����� ���������� ������������ ���. �������� ��� ��������� �������:

w.WriteStartElement("root");
w.WriteAttribute("xmlns", "x", null, "urn:1");
    w.WriteStartElement("item","urn:1");
    w.WriteEndElement();
    w.WriteStartElement("item","urn:1");
    w.WriteEndElement();
w.WriteEndElement();

� ���������� ������� ���������:

<root xmlns:x="urn:1">
    <x:item/>
    <x:item/>
</x:root>

� ���� �������, ���������� ������������ ��� ���������� � ��������� ��������, ����� �������� ������������ ��� ���� ����������� ���������. �������� ����� ����������� ������� �� ���������� ������������ ���.

������ ���������� ������������ ���

�� ������ ������� �������� ������������ ���, ��������� � ������ ��������� ��������� �������:

w.WriteStartElement("x","node","123");
w.WriteAttribute("xmlns","x",null,"bar");

� ���������� ������� ���������:

<x:node xmlns:x="bar"/>

��������, ��� "bar" �������� �������������� ������������ ��� URI "123". ��� ��������� �������� ��� ������������� ����������.

����������� ���������

�� ������ ���������� ������� ��� �������������. ��� ����� ���������� ��� �������. ������, ���� ���������� ������, ������� �������� �������:

XmlTextWriter w = new XmlTextWriter(Console.Out);
w.WriteStartElement("x","root","urn:1");
    w.WriteStartElement("y","item","urn:1");
    w.WriteEndElement();
w.WriteEndElement();
w.Close();

� ���������� ������� ���������:

<x:root xmlns:x="urn:1"><y:item xmlns:y="urn:1"/></x:root>

��������, ��� ��� �������� "x" � "y" �����������.

�������� ��������: ����������� �������� � ������� ������������ ��� URI �������� Section 2 W3C ������������ ��� � ������������ Xml (http://www.w3.org/TR/1999/REC-xml-names-19990114/ns-decl).

������������� ���������� ����������� ���

����� ���� ������������� ���������� ������������ ���, ������������ ��������� �������� ������ � ���� �� URN, XmlWriter �������� ����� ������� ���� ���������� ������������ ��� ��������� �������:

XmlTextWriter w = new XmlTextWriter(Console.Out);
w.WriteStartElement("x","root","urn:1");
    w.WriteStartElement("y","item","urn:1");
        w.WriteAttribute("foo","urn:1","bar");
    w.WriteEndElement();
w.WriteEndElement();
w.Close();

� ���� ������, ������ WriteAttribute �� ��������� ������� ������� (��� ��� �� ������ �������� ����� ��������). XmlWriter ������� ������� ������� "y" � ���������� ���, ����� ������������� ���������:

<x:root xmlns:x="urn:1">
    <y:item y:foo="bar" xmlns:y="urn:1"/>
</x:root>

����������� ���������� ����������

����� �� �������������� �������� ����� ��������� ���������, ��� ���������� ������� XmlWriter ���������� �������������� ��������. � ��������� ������� ������� ����� ����� ��� �� ����� �������, ��� � �������, �� ������������ ��� ����� ����������:

w.WriteStartElement("x","root","urn:1");
    w.WriteAttribute("x","foo","urn:2", "123");
w.WriteEndElement();

�������� "foo" ������������� ����� ������� ��������� �������:

<x:root n1:foo="123" xmlns:n1="urn:2" xmlns:x="urn:1"/>

��� ��������� ����� ��������� ������ � ���������. ��� ��������� ���������, ����� ���������� ������������ ��� ����� ������ ����������������, ��� � ������� ���������� ��������. ��������, ���������� ��������� ���:

w.WriteStartElement("x","root","urn:1");
    w.WriteStartElement("x","item","urn:2");
    w.WriteEndElement();
w.WriteEndElement();

� ���������� ������� ���������:

<x:root xmlns:x="urn:1">
    <x:item xmlns:x="urn:2"/>

3. ���������� Document Object Model (DOM)
3.1. ��������������� ������ Xml DOM
3.2. ����������� ������ Xml DOM
3.3. XmlNavigator � ��������� Xpath
3.4. XslTransform � ��������� XSLT
3.5. ����������� ����� XmlResolver

3. ���������� Document Object Model (DOM)

��������� .NET Framework SDK ���������� W3C Document object Model (DOM) level 1 Core � Core DOM Level 2. DOM - ��� memory-resident (���) ������������� ������ Xml ��������� � ��������� ��������� � �������������� ����� ���������.
����� XmlNode (System.Xml.XmlNode) - ��� ���������� W3C Document Object Model (DOM). �������������� ���������, ��� DOM Level 1, ��� � DOM Level 2. ����� XmlDocument (System.Xml.XmlDocument)) �������� ����������� XmlNode, � ������������ ������ ��� ������������� �������� ��� ���������� � �����, ��������, �������� ��� ���������� � XML �����.
XmlDocument ������������ �������� ��������� � ���������� ������ ������� XML ���������, � �� ������ ������� (current) ����, ������� ������������ XmlNavigator.
XmlDocument � XmlNode ����� ��������� ������ � ��������:
- ��������� � �������� ����, ������������ � DOM, ��������, ��������, ��������, ���������� ������, �����, �����������, �������������� �������, � ��������.
- ���������, ��������, � ������� ������ � ��������������� DOM ����.
- �������������� ������ ����� (��������, ������ ���� "programming instruction") ��� �������������� ������ ����� (��������, ������ " target" ���� "programming instruction").

����������: ���� ���������� ��������� �� ���������� ��������� ��������������� DOM, ������ XmlTextReader � XmlTextWriter ������������ ������� (non-cached) ����� forward-only ������� � XML (��. �. 2. ������ � ������ Xml).

3.1. ��������������� ������ Xml DOM

������������ W3C Document Object Model (DOM) Level 1 (http://www.w3.org/TR/REC-DOM-Level-1) ���������� ��� ������ ����������� �������: �������� � �����������. �������� ������ W3C �������� �� ����������� ��� ��������� ���������� ��������, ������� ��������� Xml �����������. W3C ���������� ����������� ������ ��� ��, ������� ����� �� ������� ������� ���������������� ����� ������� ��� �������������. ������������ W3C Level 2 DOM (http://www.w3.org/TR/DOM-Level-2-Core/) �������� ��������� ����������� ��� Xml � ��������� �������������� �����������.
� ������� ���� ������� �������� (���������������) ������ DOM, ������� ���������� ��� ��������� ���������� ��������, ����������� Xml �����������.

������ ��������
XmlNode ������������ ��������� ���� � ������ ��������� - �������� ����� ��� ������� � ������ � ������ Xml �������. XmlNodeType ���������� ���������� ���� ����. ���� ��� ���� �������� ��������� ��� ����� ������, ����������� ���, � ����������� ����� ��������� (Document Type Definitions - DTDs).
XmlNodeList ������������ ������������� ������������ �����. ������������ ������������ � ��������� ������ ������� � �������� ������������ �������� XmlNode. ���� ������ ���������� �������� ��������� � ���������.
XmlNamedNodeMap ������������ ������������ �����, � ������� ����� ���������� �� ����� ��� �� �������. � ����������� �������� � ������ �� �����.

3.2. ����������� ������ Xml DOM

���� ����� � ����������� ��������������� ������� ��� high-level �������� ������� ���� ���� � ��������� Xml. ����������� high-level �������� ��������� �������� � ������ ��������� ������� XmlNode, � ��������� ��� �������� � ������, ����������� ��� high-level �������.

����� ��������
XmlDocument Class ������������ ������ ���� Xml ���������. XmlDocument ����� ����������� W3C Document Object Model (Core) Level 1 � DOM Core Level 2.
XmlAttribute ������������ ������� XmlElement �������. ���������� �������� � �������� �� ��������� ��� �������� ���������� � DTD ��� �����.
XmlAttributeCollection Class ������������ �������� XmlElement. ���������� �������� � �������� �� ��������� ��� ������� ���������� � DTD (Document Type Definition) ��� �����.
XmlCDataSection ������� ��� ����� ������ ������, ����������� ��� ����, ����� ����� �� ����������������� ��� ���� ��������.
XmlCharacterData ������������ ������ ����������� �������, ������� ������������ ����������� ���������.
XmlComment ������������ ������� Xml �����������.
XmlDeclaration ������������ ���������� Xml �����, <?xml version='1.0' � ?>.
XmlDocumentFragment ������������ �������� ��� ����� ������ ���������. ��� ������� ��� �������� ������� ������.
XmlDocumentType �������� ����������, ��������� � ����������� ���� ���������.
XmlElement ������������ ������ �������.
XmlEntity ������������ parsed ��� unparsed �������� � Xml ���������.
XmlEntityReference ������������ �������� ������ ����.
XmlImplementation ������������ ������ ��� ���������� ��������, ������� �������� ������������ �� ������ �������������� ���������� ��������� ������ ���������.
XmlNotation �������� ����������, ����������� � DTD ��� �����.
XmlLinkedNode ���������� �������� ����, �������������� ��� ����������� �������� ����.
XmlNamedNodeMap ������������ ������������ �����, � ������� ����� ���������� �� ����� ��� �������.
XmlProcessingInstruction ������������ ������� ���������, ������� ���������� Xml ��� ���������� processor-specific ���������� � ������ ���������.
XmlSignificantWhitespace ������������ ��������� ������� �������� ��� ��������.
XmlWhitespace ������������ ��������� ������� �������� ��� ��������.
XmlText ������������ ��������� ������� �������� ��� ��������.

3.3. XmlNavigator � ��������� Xpath

����������� ����� XmlNavigator ������������ ����������� �������� ������������ � �������������� XML ������ � XML ���������. �� ������������ ��������� Xpath, � ����� �������������� ��� ������� �������� ������ XslTransform, ������� ������������ ���������� � XSLT ��������������. DocumentNavigator ��������� XmlNavigator ��� XmlDocument � DataDocumentNavigator ��������� ��� ��� XmlDataDocument.

XmlNavigator ����� ��������� ������ � ��������:

- Move, delete, insert � copy (�����������, ��������, ������� � �����������) ������ ������ ���� � �������� Xml ���������. ������� "current" ���� �������� �����, �� ������� �������������� �����������, ���� ���� �� ���������, ���������� ��� ������ ���-���� �����.
- �������� ������, ������ �� ������� ����� ������������ ����������� ��������� �� Xml ���������.
- ��������� � ����������� ������� ���� � ��������.
- ����������� "current" ���� � �������� ��� ���� (��������� ����: first, last, next, child, parent).
- ����������� �� ��������� � �������� ����.
- ����� ������������ �����, ������������ ��������� Xpath, � �����, ����������� �� ����� � �������� ����� ������������.
- Move, copy, insert � delete ��� ���� � ��� ��������; �� ���� �����������, ����������� � ��� �����, ����� ������ ������ ����.

�������� ������ ������ ��� XmlNavigator �� �� ����� ��� � � DOM. XmlNavigator ������������ ����������� ���� � ������ ����� � ��������� ��������� ������������:

- ����� ����������� ����, �� ������� ��������� XmlNavigator, ������ �� ������ ��� ��������� � ������ ������, XmlNavigator ���������� ��������� �� ���� ������������ ����, � MoveToParent ����� ������������ � ���������� ������ ����.
- MoveToNext � MoveToPrevious �� ������� �� ����� ������, ��������, ����� �������, XmlNavigator � �������������� ���������.
- ����� ����������� ����, �� ������� ��������� XmlNavigator, ��������� � ������ ����� ������, XmlNavigator ������������� ������ � ���.
- XmlNavigator ������ ��������������� �� ����. � ������ ���� ������������� ������, ������������ ������, XmlNavigator ������, ��� ��� ���������.

XmlNavigator ���������� ���� ���� � �������� ������ ������� �������������� XmlReader (���� �� ��������� ����� ���� ��������) � ��������� ��������� ��� ������������� �������. ������, XmlNavigator �� ������ ������ ����, ��� ��������� ������������ ������ � ����� ������� ������� � XML ������, ����� ������������ ����, ����� ���������� ����������� � ����. API ���� ��� ����������� �������� ������� ���� � ��������� � ��������� � ��� �����.
� ������� Xpath (http://www.w3.org/TR/Xpath), �������������� � ������������ XmlNavigator, ���������� Xpath ������� (��������. Books/Book/Price/Text) � ������������� � ���� �������� ����. ����� Select ������������� ��� ����������� ������ �� ������ ����� � ������� ��������� Xpath, � ����� MoveToSelected ��� ��� ����������� ������������� � ������ ���� � �������� �������. Xpath - �������� ����������� � ������������� ���� ������� � �����.

�������� � ����� ��������� Null

���� XmlNavigator ��������� � ��������� null, �� �������� �� ��������� �� �� ����� ����. ����� XmlNavigator ����������� � ������� null (MoveTo (null)), ���������� ���� �������� �������������� � ����������� InvalidPosition. �� ������ ��������, ��������� �� ������ XmlNavigator � ��������� null, ��������, ������������ �� NodeType 0. �� ������ ������� ������ XmlNavigator �� ��������� null, ��������� MoveTo (XmlNavigator) ��� MoveToDocument.

3.4. XslTransform � ��������� XSLT

���� Xml ��������� ���������������, ���������� ��������� ����� �������, ����� ���������� ���� ��������������� ��-�������. eXtensible Stylesheet Language (XSL) - ��� ���������� �� Xml ����, ��������������� ��� �������������� ������ Xml ��������� � ������ Xml, �������� HTML ��� � ����� ������ ����������������� ��������. XSL ������� �� Xpath, ��� ��������� ���������� ������������� ����� Xml ��������� � ������������� �������.
����������� ����� XslTransform � ������������ �� ������������� W3C XSL Transformations (XSLT). XslTransform ��������� ������� ������ XSLT, ��������� XmlReader � ��������������� ������� ������, ������������ XmlNavigator.
����� ��������� ��������������, Xml Framework ���������� ��������� XSLT � ���� ����� XSL, ������� �������� ��, ��� ������� ��������������. ���� ����� ��������� �� ��������, ������� ����������, ��� ������ ���� ��������� ��������� Xml ������ ���������� � �������������� Xml ���������. ��������� XSLT �������� ������������ � ����� ���������, ���� - ��� �������� Xml, ������ - ��� �������������� ��������� � ������ - ��� ����� �����.
����� �������������� XslTransform ��������������� ������ � ��������� XmlNavigator � ������� �� � ���� �� ��������� ����������:

- XmlReader
- XmlWriter
- TextWriter
- Stream

�������� ��������, ��� ��������� �������������� ��������� � ���������� � �����. ������� �������, ���� ������� ���� ���������� �� ��������� ������ ���� � �������� �� ��������� ���� ���������, ��� �� ��������� �������������� ���� ��������� ����� ������������ ���������. ����� ����, ��� �������������� ���� ���������, XmlNavigator ������� � ��� �������������� ���������. ��� ��������, ��� ����, ������� ��� ������� ����� ��������� ��������������, ��� ��� ������� ������� ����� ����� ����, ��� ��� ������ Transform �����.

3.5. ����������� ����� XmlResolver

����������� ����� XmlResolver ������������ ��� ���������� ������� XML ��������. XmlUrlResolver ��������� ���� �����, ����� ��������� ����� XML �������, ��� URI. �� ������������ XmlTextReader, ����� ��������� ������� DTD, �������� � �����. �� ������������ ����� XslTransform, ����� ���������� �������� <xsl:include>.

4. XmlDataDocument � Dataset
4.1. ��� Dataset ���������� ��������� ��������� ��� �����
4.2. ������������� XML .NET Framework

4. XmlDataDocument � Dataset

Microsoft .NET Framework SDK ����������� Xml c ����������� ������� XmlDataDocument. ����������� ������ ���������� ������������ ������������� ������ ������ �������������� ��������, ��������, ���������� � ������ � �������� ���������� ������ ������. ����������� ������ ���������� ������ � �������� �� �������� � �������. XML DOM ������������ ���������� � ������ XML ����, � ���������� ����������, ��������, ������ � �������� �������� � WEB, ��� ������� ���������.
XmlDataDocument ��������� XmlDocument � ������������ ������������� � Dataset ���, ��� ��� ����������������� �� �������.

������ ����� ���� ��������� � XmlDataDocument ���������� XmlReader. � Dataset ������ ����� ���� ��������� � ������� ������������ ���������� �� ������������ ��������� ������ (��������, ���� ������ SQL Server) ��� ���������� XmlReader �� XML ��������� ��� ������. �������� Dataset ��� XmlDataDocument �������������� ������ ����� ����. ������� �������, ����� ������, ����������� � Dataset, ������ ������������� ����� ����� � XmlDataDocument. �������� ����� ��������. ���������� ����� � XmlDocument ����� �������� � ��������� ����� ������ � ������� Dataset, ���� ���� ��� ���� ��������� � ������� Dataset. ���������� ������������� ����� XmlDocument � Dataset. (�� ���� Dataset, ���� �� ���������� ����������� ������, �������� �������������� XML ������) �������������, XmlDataDocument ���� ��� ����������� ��������� ����������� ��� XML ������ � ��������� ���, ��������� ��������� ������ ��������� (DOM).
������������� XmlDataDocument � DataSource �������������� �� ��������. ��� �������� � ������ ��������� ������������� DataSource � XmlDataDocument, ���������� ������ � Dataset ������ ������ ��������������� ���� � XmlDataDocument. ���� ������������ ��������� �������� ������������� XmlDataDocument � Dataset, ���������� ���� � XmlDataDocument ������ ����� ������ ������ � Dataset, ���� ����� ���� ������������ ��� �������� ������ � Dataset. XML �������� ����� ��������� ��������, ������� �� ������������� ����������� �����������.
���������� ��������� ����� ������������ XmlDataDocument ��� ���������� XML � ����������� ������������� ��� �� ����� ����������� ������, ���������� �� ��������� ������. ���� �������� ����� XML � ������������ ���������������. � XML ������, ������� �� ��������� � ������������ ����, ������ ����������, ��� � �������� Tables � Rows � ����������� ���������. ������, �� �� ������ ��������� �� ����������� ����� � ���������� XML ���������, ����� �������� ����������� ��������� � ���� XML ������.
XmlDataDocument ����� �������������� �� ���� �������, ����� ������������ XmlDocument. �������� Dataset ���������� ������ Dataset, ������� ������������ ����������� ������������� ������ � XmlDataDocument. ����� ��������� ����������� ������, ���������� Dataset, ���������� ����������� ������, �� ����� �������� XmlDataDocument. ����� ��������� ����������������� XML ������ � XmlDataDocument, ����������� ����� Load, ����������� XmlDataDocument �� XmlReader. ���� �� �������� ������ XmlDataDocument, � ��� ������������� ��������� ����� ������, ����� ������ ����� ������, ������� ����� ����������� XmlDataDocument ��� ������ ��������� ���������� � �������� Dataset � XmlDataDocument.
����� �� ���������� Xml ������ � Dataset, ��� ����� ���������, ����� ����� ���������� Xml ������ � �����������. ����� ��������� ������� � ���� ������ � ��� �����, ��� ������������� ���� Xml � ���������� ��������� � ��������� ������������ ����. ���� ��� ������� ���������� �����:

- �� ������ ��� ����� ����������� XDR ��� XSD ������ ��� Dataset, ����� ������ Xml ������. � ���� ������, Dataset ���������� ����� ��� ����������� ������, ��������� ����������� ������ ������. ����� ������ ������� �������� Relational Schema Mapping (����������� ����������� �����).
- Dataset ����� ������������ ������ � ����� ������, � �� ��������� Xml ������ ������������ �����. ����� ������ ������� �������� Inference.

�����, ��������� ������ ��������, ��������� ��� ������, �� �� ����������� ��� ����� ������ ������. ����� ������� �����, Dataset ���������� �������, ��������� � �������, ����������� ����, ��� Dataset ���������� ��������� ��������� ��� �����.

4.1. ��� Dataset ���������� ��������� ��������� ��� �����

����� ����� ReadXml ������� Dataset ��������� XML ��������, ������� �� ����� ��������� �����, Dataset ������� ��������� ���������, ��������� ���������� ��������� ������. ����� ����� - ��� ���� ������� �������. ������� Dataset ��������� ��������, ������� �������� ���� ���������� ��� ������� � � ������������ � ���������, ������� ��������� ����. ����� ����� ���������� �������� - ��� ������������ ������� � ����� �� ������������ ������.

����������� Dataset

���� �������� ���� ��������� �������� ��������, ������� �� �������� ���������, �� �������� ���� ���������� ��������. �����, �������� ���� ���������� Dataset. Dataset Name, Namespace � Prefix ����������� �� Document Element LocalName, NamespaceURI, � Prefix. ���� Document Element �������� ��������, ��� ���������� � ����������� �������� Dataset.

����������� ������

��������� ������� �������������� ��������, �� ������� ������� ������������ ��� �����:
- �������� � ���������� ������������� ���������� ���������.
- ����� �������, ������� �������� ������ �������, ���������� ��������.
- ���� ������� � ��� �� ����� ������ ����������� ����� ��� ��������, �� ���������� ��������.
- ��� ������ ���������� ��������� ���� ���������� ���������. ���� ������� ����� ������ ������������ ��������� ��������, �� � ������� ����� ��������� ������������ ������� � ��������� <ElementName>, � ���������, ���������� ����������� ����.

����������� ������������� ������

��������� ������� - Xml ������������� ������������� ��������� � ����� ��������� �������� � �������� ������������ �������. ���������� �������� ������, ����� ������� ������ � ������ ��������, ������� ����� �� �� ����� ���.

����������� ���������

��� ������������ � ���������� ������ � ����� ������� ����������� �������������� �������, ������� �������������� ��������� ����� ���������. ��� ����� ������, ��� ����������� ������� - ��� ��� ������������ ������� � ���������� "_Id". ��� ��������� - ��� ������ "Relation", ����������� ����� ������, ������� ������ ��� ��� ���������� � �������� Dataset.

�������� ������ ���������

������ ������ ������������ ������� ����� ���������� �������� ��������, � ��������� ������� ��� ������ ������ � ���������� ������� ��������� �� �� ����� ��������.

����������� ��������

��, ��� �� ���� ���������� ��� �������, ���������� ��������. ��������, ������� �� ��������� ��������������� ��� �������� �����, ������� �� ����������� � �� ����� ������� ����������� ���������, ���������� ��������� ����������� �� ��������. � �������� ����� ������� ������������ ��� ��������.
��������� Table, ������� �������� �����, ����� ��� ��������� ���������, ����������� �������������� �������, ������� ������������ ��������� ��������. ������ ����� ������� �������� ��� ��������, �������������� ���������� "_Text". ���� ��� ���� ������� � ���� ������, � ����� ����������� �����, ��� ������ ��� ����������.

����������� �����

������ ��������� �� �������� Xml �����. ���� ��������� ������� ����������� ��� ������ �������� � ������ �������:
1. ���� ������� ������������� �������� Xml ������, �� ��������� �������� �������� � ������ �������.
2. ���� ������� ��������� ������� �� ������������ � Xml ������, �� �������� ��������������� � ������������ �� ���������� ��������:
- ���� ������� �������� TextOnly, �� ��� �������� ��������������� � String.Empty.
- ���� �������� Column.AllowNull = False, �������������, �������� ��������������� � Column.DefaultValue.
- ���� �������� Column.AllowNull = True, �������������, �������� ��������������� � DBNull.

4.2. ������������� XML .NET Framework

���������� ����� ������� ������������� � ������������ ���������, ��������� ������ ��������. ���� �� ������������ ������������ ����������� ���� �����, ����� �������� ����� ��� �������� ������, ������� ��� �� ��� �� ����������� ����� �� �����: [email protected]

5. ��������� ����� System.Xml

���� ������ �������� ��������� �����, ���������� � ������� ���� System.Xml �������� ������������ ���.

booksSchema.xml
<?xml version='1.0'?>
<bookstore xmlns="urn:bookstore-schema">
  <book genre="autobiography">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <book genre="novel">
    <title>The Confidence Man</title>
    <author>
      <first-name>Herman</first-name>
      <last-name>Melville</last-name>
    </author>
    <price>11.99</price>
  </book>
  <book genre="philosophy">
    <title>The Gorgias</title>
    <author>
      <name>Plato</name>
    </author>
    <price>9.99</price>
  </book>
<bookstore>

booksSchemaFail.xml
<?xml version='1.0'?>
<bookstore xmlns="urn:bookstore-schema">
  <book>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
  </book>
  <book genre="novel">
    <title>The Confidence Man</title>
    <author>
      <first-name>Herman</first-name>
      <last-name>Melville</last-name>
    </author>
    <price>11.99</price>
  </book>
  <book genre="philosophy">
    <title>The Gorgias</title>
    <author>
      <name>Plato</name>
    </author>
    <price>9.99</price>
  </book>
</bookstore>

newbooks.xml
<?xml version='1.0'?>
<bookstore xmlns="urn:newbooks-schema">
  <book genre="novel" style="hardcover">
    <title>The Handmaid's Tale</title>
    <author>
      <first-name>Margaret</first-name>
      <last-name>Atwood</last-name>
    </author>
    <price>19.95</price>
  </book>
  <book genre="novel" style="paperback">
    <title>The Poisonwood Bible</title>
    <author>
      <first-name>Barbara</first-name>
      <last-name>Kingsolver</last-name>
    </author>
    <price>11.99</price>
  </book>
</bookstore>

schema.xml
<?xml version='1.0'?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
        xmlns:dt="urn:schemas-microsoft-com:datatypes">
  <ElementType name="first-name" content="textOnly"/>
  <ElementType name="last-name" content="textOnly"/>
  <ElementType name="name" content="textOnly"/>
  <ElementType name="price" content="textOnly" dt:type="fixed.14.4"/>
  <ElementType name="author" content="eltOnly" order="one">
    <group order="seq">
      <element type="name"/>
    </group>
    <group order="seq">
      <element type="first-name"/>
      <element type="last-name"/>
    </group>
  </ElementType>
  <ElementType name="title" content="textOnly"/>
  <AttributeType name="genre" dt:type="string"/>
  <ElementType name="book" content="eltOnly">
    <attribute type="genre" required="yes"/>
    <element type="title"/>
    <element type="author"/>
    <element type="price"/>
  </ElementType>
  <ElementType name="bookstore" content="eltOnly">
    <element type="book"/>
  </ElementType>
</Schema>

schema1.xml
<?xml version='1.0'?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
        xmlns:dt="urn:schemas-microsoft-com:datatypes">
  <ElementType name="first-name" content="textOnly"/>
  <ElementType name="last-name" content="textOnly"/>
  <ElementType name="name" content="textOnly"/>
  <ElementType name="price" content="textOnly" dt:type="fixed.14.4"/>
  <ElementType name="author" content="eltOnly" order="one">
    <group order="seq">
      <element type="name"/>
    </group>v     <group order="seq">
      <element type="first-name"/>
      <element type="last-name"/>
    </group>
  </ElementType>
  <ElementType name="title" content="textOnly"/>
  <AttributeType name="genre" dt:type="string"/>
  <AttributeType name="style" dt:type="enumeration"
        dt:values="paperback hardcover"/>
  <ElementType name="book" content="eltOnly">
    <attribute type="genre" required="yes"/>
    <attribute type="style" required="yes"/>
    <element type="title"/>
    <element type="author"/>
    <element type="price"/>
  </ElementType>
  <ElementType name="bookstore" content="eltOnly">
    <element type="book"/>
  </ElementType>
</Schema>



����������� � ���� ��������� ( )
������ �� ��� ���������: //www.vb-net.com/dotnet/XmlNet.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < �������������>