-1

I have XML file and I need to parse them,and then to write this in database,and vice versa. In database i have 2 table where to write informations. XML code: http://pastebin.com/x9Y4ekvJ

Id="134" is for first table, and id="448" is for second. Problem is some kind of references there. Look at id="448" and to <Property columnName="EMPLOYERS">. There is also <GidValue SomeType="134" entityId="2" /> and this mean that below column name EMPLOYERS and need to write name of company which have SomeType id=134' and entityId="2" and as you can see name of that company is SomeCompany2. How can i do it?

Second problem is that i dont know how to open or manipulate with .db3 file in my c# code. I looking for answer but i cannot find anything what can help me.

If some can help me, i would be grateful. Sorry for bad english.

har07
  • 88,338
  • 12
  • 84
  • 137
gzsun
  • 209
  • 1
  • 11

1 Answers1

0

By parsing you understand deserialization? Here's a class for that.

The names in bracket are the names from Xml. Each class must be public and include a public (no arguments) constructor. Each serialized variable must be public.

using System.Xml.Serialization;

namespace PsihoXXX
{
    [XmlRoot("Tag")]
    public class Tag
    {
        [XmlElementAttribute("SomeType")] 
        public SomeType[] someType;

        public Tag()
        {
        }
    }

    public class SomeType
    {
        [XmlAttribute("id")] 
        public int id;

        [XmlElementAttribute("ResourceDescription")] 
        public ResourceDescription[] resourceDescription;

        public SomeType()
        {}
    }

    public class ResourceDescription
    {
        [XmlAttribute("entityId")] 
        public int entityId;

        [XmlElementAttribute("Property")] 
        public Property[] property;

        public ResourceDescription()
        {
        }
    }

    public class Property
    {
        [XmlAttribute("columnName")] 
        public string columnName;

        [XmlElement("Value")] 
        public string value;

        public Property()
        {
        }
    }
}