System.Xml.XmlTextReader.GetAttribute C# (CSharp) Method

GetAttribute() public method

public GetAttribute ( int i ) : string
i int
return string
        public override string GetAttribute(int i)
        {
            return _impl.GetAttribute(i);
        }

Same methods

XmlTextReader::GetAttribute ( string name ) : string
XmlTextReader::GetAttribute ( string localName, string namespaceURI ) : string

Usage Example

        public static MapLayer LoadTmx(string xmlFile)
        {
            XmlTextReader reader = new XmlTextReader(xmlFile);

            MapLayer map = null;

            while (reader.Read())
            {
                if (reader.Name.Equals("layer"))
                {
                    map = new MapLayer(Int32.Parse(reader.GetAttribute("width")), Int32.Parse(reader.GetAttribute("height")));
                    for (int i = 0; i < map.Height; i++)
                    {
                        for (int j = 0; j < map.Width; j++)
                        {
                            while (reader.Read())
                            {
                                if (reader.Name.Equals("tile"))
                                    break;
                            }
                            reader.MoveToContent();
                            map.SetTile(j, i, new Tile(Int32.Parse(reader.GetAttribute("gid")) - 1, 0));
                        }
                    }

                    break;
                }
            }

            reader.Close();

            return map;
        }
All Usage Examples Of System.Xml.XmlTextReader::GetAttribute