HOW TO: BETA: ??? ?????? ?? ??????? XML ?????? ???????? System.Xml ?? Visual Basic .NET

?????? ????????? ?????? ?????????
???? ???????: 308066 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ????? ??????? ???? DataSet ??? ??? ??????? XML. ??? ?????? ????? ????? ??? ????? DataSet ????? ????? ??????? ???????? ???????? ADO.NET. DataSet ?? ????? ?????? ?? ??????? ???????? ???? ???? ???? ????? ??????? ? ????????? ??? ????? ?? ???? ????????. ???? DataSet ?????? ????? ?? ????????? ??? ?? ??? ??????? ???????? ???? ???????? ??? ???????.

???????

???? ??????? ??????? ??????? ?????? ??? ????? ?????? ???????? ?????? ? ??? ??????? ???? ???????:
  • Microsoft Windows XP ?? Windows 2000 ?? Windows NT 4.0 Service Pack 6a (SP6a)
  • Microsoft Visual Studio .NET
????? ??? ??????? ??? ??????? ??? ???????? ???????:
  • ???? ???? Visual Basic .NET
  • ??? ??????? ??????? (XML)

????? ??? Books1.xml

  1. ?? ??????? "????" ? ???? ??? ????? ????? 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>Ralls, Kim</author>
          <title>Midnight Rain</title>
          <genre>Fantasy</genre>
          <price>5.95</price>
       </book>
    </catalog>
    					
  3. ?? ??????? ???? ???? ??? ???.
  4. ?? ???? ?????? ???? ??????? ???????? ??? ???? ? ???? ??? ???? ???????. ?? ???? ???? ??? ????? ???? Books1.xml ??? ?? ???? ??? ???.

????? ??? Books2.xml

  1. ?? "???????" ? ?? ?????? ??? ??? ???? ???? Books2.xml.
  2. ??? XML ?????? ????? ???? Books2.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>Thurman, Paula</author>
          <title>Splish Splash</title>
          <genre>Romance</genre>
          <price>4.95</price>
       </book>
    </catalog>
    					
  3. ?? ??????? ???? ???? ??? ???.
  4. ?? ???? ?????? ???? ??????? ???????? ??? ???? ? ???? ??? ???? ???????. ?? ???? ???? ??? ????? ???? Books2.xml ??? ?? ???? ??? ???.

????? ????? ????? Visual Basic .NET

  1. ?? ?????? Visual Studio .NET ?? ????? ????? Visual Basic ????? ???? ???? ????.
  2. ?? ?????? ????????? ???????? ??????? ??? ???? ???? ????????? ????????:
    Imports System.Xml
    					
  3. ??? ???? ???????? ???????? ??????? ?? ??????? ??????? Sub:
            Dim xmlreader1 As New XmlTextReader("C:\Books1.xml")
    
            Dim xmlreader2 As New XmlTextReader("C:\Books2.xml")
    
            Dim ds1 As New DataSet()
            Try
                ds1.ReadXml(xmlreader1)
    
                Dim ds2 As New DataSet()
                ds2.ReadXml(xmlreader2)
    
                ds1.Merge(ds2)
                ds1.WriteXml("C:\Books.xml", XmlWriteMode.IgnoreSchema)
                Console.WriteLine("Completed merging XML documents")
            Catch ex As Exception
                Console.WriteLine(ex.Message)
            End Try
            Console.Read()
    					
  4. ?????? ??????? ???????. ???? ???? ??????? "????? ??? ??????? XML" ?? ???? ???? ??????.
  5. ????? ???? ???? ??????. ???? ??? ??? ????? ????? Books.xml ?? ?????? ??????.
  6. ???? Books.xml. ???? ?? ??? ????? ???????? ?? Books2.xml ?? ??????? ??? Books1.xml.

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

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

???? ??????? Visual Basic .NET ?????? ??????? ??????? XML ?? ??? ????.

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

  1. ???? Books2.xml ???????? XML ?? XML ??????:
    <?xml version="1.0" ?>
    <SampleData>
    <Customer>
              <CustomerName>Bill Gates</CustomerName>
              <PricePerUnit>5.95</PricePerUnit>
              <ClosingDate>2001-12-16</ClosingDate>
    </Customer>
    <Customer>
              <CustomerName>Bill Gates</CustomerName>
              <PricePerUnit>5.95</PricePerUnit>
              <ClosingDate>2001-12-16</ClosingDate>
    </Customer>
    </SampleData>
    					
  2. ??? Books2.xml.
  3. ????? ????? Visual Basic .NET ??? ????. ???? ??? ??? ????? ????? ?? ??????? ?????? (Books2.xml) ?? ????? XML ????? (Books1.xml).

??? ??????? XML ?? ???? ?????? Where ??????? ?????? ????? ??? ????? ??????

  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>Thurman, Paula</author>
          <title>Splish Splash</title>
          <genre>Romance</genre>
          <price>4.95</price>
          <publish_date>2000-11-02</publish_date>
          <description>A deep-sea diver finds true love twenty 
          thousand leagues beneath the sea.</description>
       </book>
    </catalog>
    					
  2. ??? Books2.xml.
  3. ????? ????? Visual Basic .NET ??? ????. ???? ??? ??? ????? ????? ?? ??????? ?????? ?? ????? XML ?????.

??? ??????? XML ?? ???? ?????? Where ??????? ?????? ????? ??? ????

  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>Thurman, Paula</author>
          <title>Splish Splash</title>
          <price>4.95</price>
       </book>
       <book id="bk108" genre="Horror">
          <author>Knorr, Stefan</author>
          <title>Creepy Crawlies</title>
          <price>4.95</price>
       </book>
       </catalog>
    					
  2. ??? Books2.xml.
  3. ????? ????? Visual Basic .NET ??? ????. ???? ??? ??? ????? ????? ?? ??????? ?????? ??? ????? XML ????? ?????? ???? ??? ????? XML ?????.

??? ??????? XML ?? ???? ?????? Where ??????? ????? ????? ??? ????

  1. ????? ????????? ???????? ?? Visual Basic ??? ??? ???? ??? ????? Books1.xml Books2.xml:
            Dim xmlreader1 As New XmlTextReader("C:\Books2.xml")
    
            Dim xmlreader2 As New XmlTextReader("C:\Books1.xml")
    
            Dim ds1 As New DataSet()
            Try
                ds1.ReadXml(xmlreader1)
    
                Dim ds2 As New DataSet()
                ds2.ReadXml(xmlreader2)
    
                ds1.Merge(ds2)
                ds1.WriteXml("C:\Books.xml", XmlWriteMode.IgnoreSchema)
                Console.WriteLine("Completed merging XML documents")
            Catch ex As Exception
                Console.WriteLine(ex.Message)
            End Try
            Console.Read()
    					
  2. ????? ????? Visual Basic .NET ??? ????. ???? ?? ???? ????? XML ??????? ????? ?? Books1.xml Books2.xml. ???????? ??? ???? ???? ?? ???? ????? ???? ????? ??? ??? "?????".

    ????? ???????? ??? ???? ????? XML ????? ??? ????? ????? XML ?????? ???? ???? ???? ????? XML ???????.

?????

?????? ??? ??????? ??????? ???? ??? ??? ??????? ????? ?????? ?? "????? ??????? ?? Microsoft:
286817HOWTO: ??? ???????? ?? ??????? XML ?????? ?????? ????? ????? ???? ??????? (DOM)

???????

???? ???????: 308066 - ????? ??? ??????: 07/???/1424 - ??????: 2.3
????? ???
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft .NET Framework 1.0
  • Microsoft .NET Framework 1.1
????? ??????: 
kbmt kbhowtomaster KB308066 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????308066

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

 

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