string input = "//a/@href "; int index = input.IndexOf("/@"); String attr = input.Substring(index+2); Console.WriteLine("attr=@href");
ArrayOf
<ArrayOfTileResourceInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <TileResourceInfo> <TileMatrixMin>17</TileMatrixMin> <TileMatrixMax>17</TileMatrixMax> <LatMin>36.03515625</LatMin> <LatMax>42.626953125</LatMax> <LonMin>113.433837890625</LonMin> <LonMax>119.8828125</LonMax> <City>***</City> <TileType>***</TileType> <Style>dom</Style> <TileMatrixSet>Matrix_0</TileMatrixSet> <Layer>dom</Layer> <Format>image/tile</Format> <Uri>http://110.249.157.236/domTile/wmts</Uri> </TileResourceInfo> <TileResourceInfo> <TileMatrixMin>17</TileMatrixMin> <TileMatrixMax>17</TileMatrixMax> <LatMin>27.037353515625</LatMin> <LatMax>32.0</LatMax> <LonMin>117.1636962890625</LonMin> <LonMax>123.189697265625</LonMax> <City>*****</City> <TileType>****</TileType> <Style>ZJDOM2W1</Style> <TileMatrixSet>Matrix_0</TileMatrixSet> <Layer>**********</Layer> <Format>image/tile</Format> <Uri>******************</Uri> </TileResourceInfo> </ArrayOfTileResourceInfo>
Type type = typeof(T); T ass = (T)Assembly.GetAssembly(type).CreateInstance(type.FullName); XmlDocument xdResult = new XmlDocument(); XmlDeclaration dec = xdResult.CreateXmlDeclaration("1.0", null, null); xdResult.AppendChild(dec); XmlElement root = xdResult.CreateElement(type.Name); xdResult.AppendChild(root); XmlElement xe = xdResult.CreateElement("Name"); xe.InnerText = "羊驼"; root.AppendChild(xe); XmlSerializer xs = new XmlSerializer(type); StringReader reader=new StringReader(xdResult.OuterXml); T o = (T)xs.Deserialize(reader);