Working with XML

前端 未结 3 613
青春惊慌失措
青春惊慌失措 2021-01-16 20:17

I\'m planning to create a news item which uses xml as it\'s backend and the Display should be like:

Date: 08/Mar/2010
------------------------------
Title &

3条回答
  •  日久生厌
    2021-01-16 21:11

    There are a million ways to do this. The approach I'd take in the situation you described:

    1. Build an class whose properties are the data elements I need to collect.
    2. Either use XML serialization (if I'm not conforming to a specific schema, this is the approach requiring the least code) or build a method into the class that used XDocument or XmlWriter to produce the XML.
    3. Write test cases to test the class and its XML-generation method.
    4. Build the form.
    5. Bind the UI controls to the properties of an instance of my class.

    What I wouldn't do: Write a method in the form that pulls data out of the form controls and writes them to XML.

提交回复
热议问题