public void Add(DocumentDataTable table)
        {
            var tbl = GetDataTable(table.TableName);

            if (tbl != null)
            {
                throw new InvalidOperationException(string.Format("There is already a table named {0} in the document data.", tbl.TableName));
            }
            _dataTable.Add(table);
        }
        public static DocumentData Load(XmlDocument xmd)
        {
            var documentData = new DocumentData();

            var nodes = xmd.GetElementsByTagName("Data");

            foreach (XmlNode node in nodes[0])
            {
                documentData.Add(node.Name, node.InnerText);
            }

            var tables = xmd.GetElementsByTagName("Table");

            foreach (XmlElement table in tables)
            {
                var tableName = table.GetAttribute("Name");
                var t         = new DocumentDataTable(tableName);
                documentData.Add(t);
                foreach (XmlElement row in table.ChildNodes)
                {
                    switch (row.Name)
                    {
                    case "Row":
                        var rw = new Dictionary <string, string>();
                        t.Rows.Add(new DocumentDataTableData(rw));
                        foreach (XmlElement col in row)
                        {
                            rw.Add(col.Name, col.InnerText);
                        }

                        break;

                    case "Group":
                        t.Rows.Add(new DocumentDataTableGroup(row.InnerText));
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(string.Format("Unknown row type {0}.", row.Name));
                    }
                }
            }

            return(documentData);
        }