泰山脚下

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

XML文件内容

<?xml version="1.0" standalone="no"?>
<svg width="1709px" height="886px"  onload="init(evt)"  viewBox="0 0 1800 900" xmlns="http://www.w3.org/2000/svg"  xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
   <rect width="1709px" height="886px" fill="GradientInactiveCaption" />
   <rect x="88" y="369" width="1200px" height="15px" stroke-width="1" stroke="Black" fill="url(#79)" />
   <rect id="REED.ShapeElement.TrapezoidR" x="491" y="283" width="80px" height="185px" stroke-width="1" stroke="Transparent" fill="Transparent" />
</svg>

以下是读取方法:

class Program
    {
        static void Main(string[] args)
        {
            try
            {

                XmlDocument xmlDoc = new XmlDocument(); 
                xmlDoc.Load("F:\\汽机本体2.svg");

                XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
                nsmgr.AddNamespace("ns", "http://www.w3.org/2000/svg");
                XmlNode xn = xmlDoc.SelectSingleNode("//ns:svg", nsmgr);
                XmlNodeList xnl = xn.ChildNodes;
                Console.WriteLine("读取成功");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadLine();
                throw;
            }
            
        }
    }
posted on 2014-07-25 16:24  泰山脚下  阅读(830)  评论(0编辑  收藏  举报