XMLElement & Attribute

    public class Phone
    {
        [XmlElement(ElementName = “WorkPhone”)]
        public string WorkPhone
        {
            get;
            set;
        }

        [XmlElement(ElementName = “HomePhone”)]
        public string HomePhone
        {
            get;
            set;
        }

        [XmlElement(ElementName = “CellPhone”)]
        public string CellPhone
        {
            get;
            set;
        }
    }

    [XmlRoot(“Person”)]
    public class Person : IComparable<Person>, IEquatable<Person>
    {
        [XmlElement(ElementName=”Name”, Order=1)]
        public string Name
        {
            get;
            set;
        }

        [XmlElement(ElementName=”ID”, DataType=”int”, Order=2)]
        public int ID
        {
            get;
            set;
        }

        [XmlElement(ElementName=”Phone”, Order=3)]
        public Phone Phone = new Phone();

        [XmlElement(ElementName=”Address”, Order=4)]
        public string Address
        {
            get;
            set;
        }

        public Person() : this(“”, 0, “”, “”, “”,””)
        {
        }

        // 중간생략
}




<?xml version=”1.0″ ?>


<ArrayOfPerson xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=”http://www.w3.org/2001/XMLSchema>



<Person>



    <Name>Park Kyoung Shin</Name>


    <ID>1207</ID>


   <Phone>



     <WorkPhone>041-550</WorkPhone>


     <HomePhone>02-379</HomePhone>


     <CellPhone>010</CellPhone>

 </Phone>


   <Address>서울시</Address>

</Person>


  <Person>



    <Name>박똑똑</Name>


    <ID>5205</ID>


   <Phone>



      <WorkPhone>10</WorkPhone>


      <HomePhone>10</HomePhone>


      <CellPhone>10</CellPhone>

 </Phone>


    <Address>단국대</Address>

</Person>


<Person>



  <Name>아무개</Name>


  <ID>1202</ID>


<Phone>



  <WorkPhone>041-550-3418</WorkPhone>


  <HomePhone>11</HomePhone>


  <CellPhone>11</CellPhone>

  </Phone>


    <Address>단국대</Address>

</Person>


</ArrayOfPerson>

Leave a Reply

Your email address will not be published. Required fields are marked *