private static XMLNode FirstLoadNode(StreamReader input, string rootName = "") { if (rootName == string.Empty) { rootName = input.ReadLine(); } var root = new XMLNode(rootName.Substring(1, rootName.Length - 2), new Dictionary <string, string>()); var nodeAttrs = root.GetDictionary(); for (string line; (line = input.ReadLine()) != string.Empty && Lstrip(ref line)[1] != '/';) { if (line == string.Concat("</", rootName.Substring(1))) { break; } if (line == Split(line, "</").Item1) { root.AddChild(FirstLoadNode(input, line)); continue; } var(name, closeAction) = Split(Lstrip(ref line), "</"); var(nodeName, value) = Split(name, ">"); nodeName = nodeName.Substring(1, nodeName.Length - 1); if (nodeName != closeAction.Substring(0, closeAction.LastIndexOf('>'))) { throw new ArgumentException("Tag is not opened/closed:" + nodeName + "!=" + closeAction.Substring(0, closeAction.Length - 2)); } if (name != string.Empty && value != string.Empty) { nodeAttrs[nodeName] = value; } } return(root); }
public void AddChild(XMLNode node) { children.Add(node); }
public XMLDocument(XMLNode root) { Root = root; }
public bool FindNode(XMLNode lhs) { return(lhs.name == _str); }