How to access fields and values from an XML Database

Dec 2 2009 6:33 PM
I have an XML Database that I am loading into a Dataset object in a C# 2008 Windows Forms project. I need to know how to access the individual fields and values. The actual database is not in my control, so I have to use it as given. And I need to be able to offer portions of the values for editing, while hiding others. So I need to how to access each individual field and value. Here is a very tiny mocked up version of the XML code:

<?xml version="1.0"?>
<database version="1.0">
    <DatabaseItem name="FirstTable">
        <DatabaseSubitem id="1">
            <DatabaseField name="Id" value="1" />
            <DatabaseField name="Freq" value="151955000" />
            <DatabaseField name="Mode" value="Mode:Selective" />
        </DatabaseSubitem>
        <DatabaseSubitem id="2">
            <DatabaseField name="Id" value="1" />
            <DatabaseField name="Freq" value="151955000" />
            <DatabaseField name="Mode" value="Mode:Selective" />
        </DatabaseSubitem>
        <DatabaseSubitem id="3">
            <DatabaseField name="Id" value="65535" />
        </DatabaseSubitem>
    </DatabaseItem>
    <DatabaseItem name="SecondTable">
        <DatabaseSubitem id="0">
            <DatabaseField name="access_p" value="500" />
        </DatabaseSubitem>
    </DatabaseItem>
    <DatabaseItem name="ThirdTable">
        <DatabaseSubitem id="0">
            <DatabaseField name="access_Short" value="500" />
        </DatabaseSubitem>
    </DatabaseItem>
</database>

If there is an easier way than the Dataset object to process the database, please let me know.

Any help would be most appreciated.
Thanks,
Bruce

Answers (4)