XML Parsing - Generic

XmlTextReader reader = new XmlTextReader(new StringReader(xml)); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: Hashtable attributes = new Hashtable(); string strURI = reader.NamespaceURI; string strName = reader.Name; if (reader.HasAttributes) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); attributes.Add(reader.Name, reader.Value); } } break; default: break; } }
StringReader is required to read XML string. Else error is thrown as Illegal characters sequence found.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.