????? ????? ????? ???? ??? XML ???????? Visual C#

?????? ????????? ?????? ?????????
???? ???????: 815813 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ???? ????? ??? ????? ????? ????? ???? ??? XML ???????? Visual C#. ???? ??? ??????? persisting ???? ??????. ??? ??????? ?????? ????? ??????? ???? ?????? de-serializing XML ??? ???? ????.



???????

???? ??????? ??????? ??????? ?????? ??? ????? ?????? ???????? ?????? ? ??? ??????? ????????:
  • Microsoft Visual Studio
????? ??? ??????? ??? ??????? ??? ???????? ???????:
  • ?????? ?????? ???????? XML
  • ?????? ?????? ?? "Visual C" #

??????? XML

?? ????? ????? ???????? ??? ??? ????? ??? ???? ???? persisting ?? ??? ?????. ????? Microsoft .NET Framework ????? ???????? ???? ???? ????? ????? ????? ?? ??? XML. ???? ????? ????? System.Xml.Serialization ??? ?????????.

???? ??????? ??????? ?????? ????? ???? ???? ???? ???? ?????? ???? ?? serializes ????? ??? XML:
  1. ?? Visual C# ? ????? "????? ???? ????" ???? ???????.
  2. ?? ??????? ??????? ???? ??? ????? ??? ?????? ??? ????? ??? ???????.
  3. ?? ???? ?????? ????? ???? ???? ????? ??? ????? ??? clsPerson.
  4. ???? ??? ?????. ??? ????? ??? ?????.

    ?????? ?? Visual Studio .NET 2003 ? ???? ??? ???.
  5. ?? ?????? ????????? ???????? ??????? ???
     public   string FirstName;
     public   string MI;
     public   string LastName;
    
  6. ??????? ??? ???? ????????? ???????? Program.cs ?? Visual Studio ?? Class1.cs ?? Visual Studio .NET 2003.
  7. ?? ??????? ??????? ????? ??????? ?????? ???? ??? clsPerson:
    clsPerson p = new clsPerson();
  8. ????? ????? ?????? clsPerson:
    p.FirstName = "Jeff";
    p.MI = "A";
    p.LastName = "Price";
  9. ????? ????? ??? Xml.Serialization ????? XmlSerializer serializes ???? ??? XML. ??? ????? ???? XmlSerializer ??? ?????? ???? ????? ???? ???? ????? ????? ??? ?????? ????? ??:
    System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(p.GetType());
  10. ??? ??????? ??????? Serialize ????? ???? ??? XML. ????? ????? ????? ??? ?????? ?? ????? ??????? ??? ???? XMLWriter ?? ????? ?? TextWriter. ?? ??? ??????? ?????? ??????? ??? ???? ??????:
    x.Serialize(Console.Out,p);
    Console.WriteLine();
    Console.ReadLine();

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

using System;

public class clsPerson
{
  public  string FirstName;
  public  string MI;
  public  string LastName;
}

class class1
{ 
   static void Main(string[] args)
   {
      clsPerson p=new clsPerson();
      p.FirstName = "Jeff";
      p.MI = "A";
      p.LastName = "Price";
      System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(p.GetType());
      x.Serialize(Console.Out, p);
      Console.WriteLine();
      Console.ReadLine();
   }
}    

??????

?????? ?? ?? ??????? ????? ?? ???? ???? CTRL + F5 ?????? ???????. ????? ???? clsPerson ???? ????? ?? ????? ???? ???????. ??? ????? ??? ?????? ??? XML. ???? ???? ???? ?????? ?? ???:
<?xml version="1.0" encoding="IBM437"?>
 <clsPerson xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3
 .org/2001/XMLSchema">
<FirstName>Jeff</FirstName>
 <MI>A</MI>
<LastName>Price</LastName> </clsPerson>

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

???? ?????? Xml.Serialization.XmlSerializer ??????? ??????? ???. ??? ??? ???? ????? ????? ????????? ?????? ????????? ???? ?? ???? ??? ???? ??????? ??????? ?????.

?????

????? ?? ?????????? ?? ?????? ???? ?????? Microsoft Network (MSDN) ?????? ??? ?????:
????? ??????? XML
http://msdn.microsoft.com/en-us/library/182eeyhh(VS.80).aspx

???????

???? ???????: 815813 - ????? ??? ??????: 18/???/1429 - ??????: 4.1
????? ???
  • Microsoft Visual C# 2008 Express Edition
  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Visual C# 2005 Express Edition
????? ??????: 
kbmt kbsweptvs2008 kbnamespace kbxml kbhowtomaster KB815813 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????815813

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

 

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