???? System.Xml ?? ????? ?? Visual C# .net ?? ????? ???? ?? XML ????????? ?? ???? ???? ????

???? ?????? ???? ??????
???? ID: 311530 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ??? ?? ??? ???? ???? ?? XML ????????? ???? ???? ?? ??? ???? DataSet ???????? ?? ????? ???? ?????? ??? DataSet ???????? ?????????? ??, ????? ???? ?? ??? ???????? ?? ???? ???????? ADO.NET ??????? DataSet ?????? ???? ?? ?? ??????, relational ???????????? ???? ?? ??? ?? ???? ????? ???? ?? ?? ?????? resident ???????????? ??? ??????? ????????, ?????? ?? ???????? ?? ??? ????? ???? ???? ?? ????? ??? DataSet ???????????? ???? ???

??????????

????? ???? ???????? ?????????, ??????????, ??????? ?????? ?? ???? ?????? ??? outlines:
  • Microsoft Windows XP, Windows 2000 ?? Windows NT 4.0 ?????? ??? 6a (SP6a)
  • Microsoft Visual Studio .net
?? ???? ????? ?? ?? ?? ?????????? ?????? ?? ??? ?????? ???:
  • Visual C# .net ????????
  • ??????????? ??????? ???? (XML)

Books1.xml ????? ?????

  1. Windows ??????? ???? ??, ????? ???? ?????, ?????? Notepad.exe, ?? ?? ???????? ?????
  2. ????? ??? ?? ???????, ??? ????-????? ????, ?? ?? ????????? ?????????? ????? ?????? ???, ?????? ???? ??, ???????????? ?????
    <?xml version="1.0"?>
    <catalog>
       <book id="bk101">
          <author>Gambardella, Matthew</author>
          <title>XML Developer's Guide</title>
          <genre>Computer</genre>
          <price>44.95</price>
       </book>
       <book id="bk102">
          <author>Jeanette, Dasha</author>
          <title>Quack the Duck</title>
          <genre>Fantasy</genre>
          <price>5.95</price>
       </book>
    </catalog>
    					
  3. ????? ???? ?? ??????????? ?????
  4. ?? ??? ??? ?????? ????? ????? ???, ?? ??? ??? ?????? ?????? ?????-???? ???? ????? ???, ??? ???????????? ????? ????? ?? ??? ??? ????? ???, ???? ???? Books1.xml, ?? ?? ??????????? ?????

Books2.xml ????? ?????

  1. ?????? ???, Books2.xml ???? ?? ??? ??? ????? ??????
  2. ????????? ????? ?? ??????? Books2.xml ??? ????? XML:
    <?xml version="1.0"?>
    <catalog>
    <book id="bk106">
          <author>Randall, Cynthia</author>
          <title>Lover Birds</title>
          <genre>Romance</genre>
          <price>4.95</price>
       </book>
       <book id="bk107">
          <author>Vinzovskaia, Irina</author>
          <title>Piano Fort A</title>
          <genre>Romance</genre>
          <price>4.95</price>
       </book>
    </catalog>
    					
  3. ????? ???? ?? ??????????? ?????
  4. ?? ??? ??? ?????? ????? ????? ???, ?? ??? ??? ?????? ?????? ?????-???? ???? ????? ???, ??? ???????????? ????? ????? ?? ??? ??? ????? ???, ???? ???? Books2.xml, ?? ?? ??????????? ?????

Visual C# .net ????????? ????? ?? ??? ???

  1. Visual Studio .net ??????? ????, ?? ?? Visual C# ????? ????????? ??? ??? ????????? ??????
  2. ??? ????? ?? ????? ?? ?????????? ??? ??????:
    using System;
    using System.Xml;
    using System.IO;
    using System.Data ;
    					
  3. ????????? ????? ?? ????? void ??? ??? (???????? [] args) ????? ??? ???????:
    try
    	{
    		XmlTextReader xmlreader1 = new XmlTextReader("C:\\Books1.xml");
    		XmlTextReader xmlreader2 = new XmlTextReader("C:\\Books2.xml");
    
    		DataSet ds = new DataSet();
    		ds.ReadXml(xmlreader1);
    		DataSet ds2 = new DataSet();
    		ds2.ReadXml(xmlreader2);
    		ds.Merge(ds2);
    		ds.WriteXml("C:\\Books.xml");
    		Console.WriteLine("Completed merging XML documents");
    	}
    	catch (System.Exception ex)
    	{
    		Console.Write(ex.Message);
    	}
    Console.Read();	
    					
  4. ??????? ?? ????????? ?????? ????? ??? ?? "XML ????????? ???? ????? ??" ????? ?????? ????? ??? ????? ???? ???
  5. ?????? ????? ??? ?? ???? ????? ??? ?? ???? ?????? ????????? ?? ??? Books.xml ????? ???? ???? ???
  6. Books.xml ?????? ????? ??? ?? Books2.xml ?? ???? ?? Books1.xml ?? ??? ??? ???? ????? ???? ???

????? XML ????????? ????????

???? ?????? ???? ?? XML ????????? ???? ????

????? Visual C# .net ????? ?????? ??? ?????? XML ????????? ????????? ???? ?? ???

??????? ???????? ??? XML ????????? ???? ????

  1. Books2.xml ?? ?????, ?? ????? XML ?? ??? XML ?????:
    <?xml version="1.0" ?>
    <SampleData>
    <Customer>
              <CustomerName>Bob Frapples</CustomerName>
              <PricePerUnit>5.95</PricePerUnit>
              <ClosingDate>2001-12-16</ClosingDate>
    </Customer>
    <Customer>
              <CustomerName>Bob Frapples</CustomerName>
              <PricePerUnit>5.95</PricePerUnit>
              <ClosingDate>2001-12-16</ClosingDate>
    </Customer>
    </SampleData>
    					
  2. Books2.xml ?? ???????
  3. Visual C# .net ????????? ???: ?????? ????? ??? ?? ????? ????? ????????? (Books2.xml) ?? ???? XML ????????? (Books1.xml) ????? ???? ????

????? ????????? ??? ???? ???????? ???? ?? ???? ?????? ?? ??? XML ????????? ???? ????

  1. Books2.xml ?? ?????, ?? ????? XML ?? ??? XML ?????:
    <?xml version="1.0"?>
    <catalog>
    <book id="bk106">
          <author>Randall, Cynthia</author>
          <title>Lover Birds</title>
          <genre>Romance</genre>
          <price>4.95</price>
          <publish_date>2000-09-02</publish_date>
          <description>When Carla meets Paul at an ornithology 
          conference, tempers fly as feathers get ruffled.</description>
       </book>
       <book id="bk107">
          <author>Vinzovskaia, Irina</author>
          <title>Piano Fort A</title>
          <genre>Romance</genre>
          <price>4.95</price>
          <publish_date>2000-11-02</publish_date>
          <description>Two young pianists strike a chord when they fight a 
          pitched battle to stop the gnomes at a key base.</description>
       </book>
    </catalog>
    					
  2. Books2.xml ?? ???????
  3. Visual C# .net ????????? ???: ?????? ????? ??? ?? ????? ????? ????????? ?? ???? XML ????????? ??? ????? ???? ????

XML ????????? ???? ????????? ????? ????????? ??? ???? ?????? ?? ??? ???? ????

  1. Books2.xml ?? ?????, ?? ????? XML ?? ??? XML ?????:
    <?xml version="1.0"?>
    <catalog>
    <book id="bk106" genre="Romance">
          <author>Randall, Cynthia</author>
          <title>Lover Birds</title>
          <price>4.95</price>
       </book>
       <book id="bk107" genre="Romance">
          <author>Vinzovskaia, Irina</author>
          <title>Piano Fort A</title>
          <price>4.95</price>
       </book>
       <book id="bk108" genre="Horror">
          <author>de Dogg, Jazz</author>
          <title>Night of the Flea</title>
          <price>4.95</price>
       </book>
       </catalog>
    					
  2. Books2.xml ?? ???????
  3. Visual C# .net ????????? ???: ?????? ????? ??? ?? ????? ????? ????????? ?? ???? XML ????????? ??? ????? ???? ???, ?? ?????? ?? ???? XML ????????? ?? ??? ??? ?? ?? ???

???? ????????? ??? ???? ????????? ??? ???? ?????? ?? ??? XML ????????? ???? ????

  1. Books1.xml Books2.xml ?? ???? ????? ???? ?? ???? Visual C# ??? ??????????? ??????? ????:
    try
    	{
    		XmlTextReader xmlreader1 = new XmlTextReader("C:\\Books2.xml");
    		XmlTextReader xmlreader2 = new XmlTextReader("C:\\Books1.xml");
    
    		DataSet ds = new DataSet();
    		ds.ReadXml(xmlreader1);
    		DataSet ds2 = new DataSet();
    		ds2.ReadXml(xmlreader2);
    		ds.Merge(ds2);
    		ds.WriteXml("C:\\Books.xml");
    		Console.WriteLine("Completed merging XML documents");
    	}
    	catch (System.Exception ex)
    	{
    		Console.Write(ex.Message);
    	}
    Console.Read();	
    					
  2. Visual C# .net ????????? ???: ?????? ??????? XML ????????? appends ????? Books1.xml ?? Books2.xml ???? ?? ??? ????? ???? ???? ??? ??, ????? ??? ?? ??? ???????? ????? "????" ??????? ?? ?????????

    ???? ??????? XML ?? ??? ???? ?? ?????, ???? XML ????????? ?? ?????? ?? ?????? ???? ???, ????? XML ????????? ??????? ???

??????

???????? ??????? ?? ???, Microsoft ???????? ??? ???? ????? ?? ??? ????? ???? ?????? ?? ????? ????:
286817 ?? XML ????????? ??? ???? ???? ????????? ???????? ???? (DOM) ???????????? ???? ?? ??? ????

???

???? ID: 311530 - ????? ???????: 30 ????? 2012 - ??????: 3.0
???? ???? ???? ??:
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft .NET Framework 1.0
  • Microsoft .NET Framework 1.1
??????: 
kbhowtomaster kbio kbsystemdata kbmt KB311530 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:311530

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com