0

我正在尝试从 XML 文件中检索我的所有数据,并将所有数据放在一个新创建的ArrayList包含. 这是测试数据:int, int, string, string,int, int, string, string, and a boolean

在我的新数组中,它将包含以下内容:

登录组

group id, name, description, number, and "array" 

登录类型

type id, group_id, title, description, enabled.

登录组

group id="0" name="Private" description="This type of login is enabled to do   whatever." display_number="1".

登录类型

type id="0" group_id="1" title="Standard" description="This login type is shortlived." enabled="false"
type id="0" group_id="2" title="Standard" description="This login type is fast paced." enabled="false"

我的 CS

public struct LoginGroupInfo
{
    public int id;
    public string name;
    public string description;
    public int number;
    public ArrayList types;       
}

public struct types
{
    public int id;
    public int group_id;
    public string title;
    public string description;
    public bool enabled;
}

if (!LoginTypes(id, out loginGroupList))
{
    MessageBox.Show("Error, nothing found");
}
else
{
    MessageBox.Show("Something, found");
}

public static bool LoginTypes(int Id, out ArrayList loginGroupList)
{
    bool success = false; // Return value.         

    //create a new list for my groups
    ArrayList loginList = new ArrayList();        

    try
    {
        // Get the "main" XmlNode.
        XmlNode groupNode = GetXmlDoc(myXmlFile).SelectSingleNode("login_groups");

        // Verify that node exists and get the rest.
        if (groupNode != null)
        {
            // Get the services XmlNodeList.
            XmlNodeList groupList = groupNode.SelectNodes("group");

            // Loop through the login-types.
            foreach (XmlNode typeNode in groupList)
            {
                success = true;
                LoginGroupInfo loginType = new LoginGroupInfo();

                // Save the relevant data.
                loginType.id = StrToInt(typeNode.Attributes["id"].Value);
                loginType.name = typeNode.Attributes["name"].Value;
                loginType.description = typeNode.Attributes["description"].Value;
                loginType.number = StrToInt(typeNode.Attributes["display_number"].Value);
                loginType.types= ?;
                //Not sure how to set this up, this is where i need the info 
                //from <login_types> to be placed inside the arraylist "types" inside the loginType.

                loginGroupList.Add(loginType);
            }
        }
    }
    return success;
 }
4

0 回答 0