In-depth parsing of XML structure and class ing

Source: Internet
Author: User

  • XML Overview
  • XmlElement
  • XmlAttribute

  • InnerText
    • Ing between Type Definitions and XML Structures
    • XmlElement
    • XmlAttribute
    {    []    IntValue { ; ; }    []    StrValue { ; ; }}
    • InnerText
    {    []    IntValue { ; ; }    []    StrValue { ; ; }}
    • Rename a node
    ()]{    [()]    IntValue { ; ; }    [()]    StrValue { ; ; }}
    • List and array serialization
    ()]: { }
    • List and array as data member serialization
    {    Class3 { ; ; }    [()]    [()]    List { ; ; }}
    {    Class3 { ; ; }    [()]    List { ; ; }}
    • Type inheritance and deserialization
    { }[()]: {    [()]    AA { ; ; }    [()]    BB { ; ; }}[()]: {    [()]    CC { ; ; }    [()]    DD { ; ; }}{    [(()),    (())] List { ; ; }}
    • Exclude non-serialized members
    {    []    IntValue { ; ; }    StrValue { ; ; }    Url;}
    • Serializing order of specified members
    {    [(Order )]    StrValue { ; ; }    [(Order )]    Url;}
    • Deserialization
    • Sample Code for reading and writing XML data
    order GetOrderById();xml XmlSerialize(order, UTF8);order2 XmlDeserialize(xml, UTF8);
    System;SystemCollectionsGeneric;SystemLinq;SystemText;SystemXmlSerialization;SystemIO;SystemXml;
    {
    XmlSerializeInternal(stream, o, encoding)        {            ( o )                ();            ( encoding )                ();            serializer (oGetType());            settings ();            settingsIndent ;            settingsNewLineChars ;            settingsEncoding encoding;            settingsIndentChars ;            ( writer Create(stream, settings) ) {                serializerSerialize(writer, o);                writerClose();            }        }        XmlSerialize(o, encoding)        {            ( stream () ) {                XmlSerializeInternal(stream, o, encoding);                streamPosition ;                ( reader (stream, encoding) ) {                    readerReadToEnd();                }            }        }        XmlSerializeToFile(o, path, encoding)        {            ( IsNullOrEmpty(path) )                ();            ( file (path, Create, Write) ) {                XmlSerializeInternal(file, o, encoding);            }        }        T XmlDeserializeT(s, encoding)        {            ( IsNullOrEmpty(s) )                ();            ( encoding )                ();            mySerializer ((T));            ( ms (encodingGetBytes(s)) ) {                ( sr (ms, encoding) ) {                    (T)mySerializerDeserialize(sr);                }            }        }        T XmlDeserializeFromFileT(path, encoding)        {            ( IsNullOrEmpty(path) )                ();            ( encoding )                ();            xml ReadAllText(path, encoding);            XmlDeserializeT(xml, encoding);        }    }

    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.