把<tcm:Data>节点读出来.然后往一个新的xml文件里写10次..-_-!

解决方案 »

  1.   

    XML不太会,老板分配的任务,帮我弄下发到我邮箱哈
      

  2.   

    public class doxml
    {
        protected string strXmlFile;
        protected XmlDocument objXmlDoc = new XmlDocument();    public doxml(string XmlFile)
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
            try
            {
                objXmlDoc.Load(XmlFile);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            strXmlFile = XmlFile; 
    }    public DataView GetData(string XmlPathNode)
        {
            //查找数据。返回一个DataView 
            DataSet ds = new DataSet();
            StringReader read = new StringReader(objXmlDoc.SelectSingleNode(XmlPathNode).OuterXml);
            ds.ReadXml(read);
            return ds.Tables[0].DefaultView;
        }    public void Replace(string XmlPathNode, string Content)
        {
            //更新节点内容。 
            objXmlDoc.SelectSingleNode(XmlPathNode).InnerText = Content;
        }    public void Delete(string Node)
        {
            //删除一个节点。 
            string mainNode = Node.Substring(0, Node.LastIndexOf("/"));
            objXmlDoc.SelectSingleNode(mainNode).RemoveChild(objXmlDoc.SelectSingleNode(Node));
        }    public void InsertNode(string MainNode, string ChildNode, string Element, string Content)
        {
            //插入一节点和此节点的一子节点。 
            XmlNode objRootNode = objXmlDoc.SelectSingleNode(MainNode);
            XmlElement objChildNode = objXmlDoc.CreateElement(ChildNode);
            objRootNode.AppendChild(objChildNode);
            XmlElement objElement = objXmlDoc.CreateElement(Element);
            objElement.InnerText = Content;
            objChildNode.AppendChild(objElement);
        }    public void InsertElement(string MainNode, string Element, string Attrib, string AttribContent, string Content)
        {
            //插入一个节点,带一属性。 
            XmlNode objNode = objXmlDoc.SelectSingleNode(MainNode);
            XmlElement objElement = objXmlDoc.CreateElement(Element);
            objElement.SetAttribute(Attrib, AttribContent);
            objElement.InnerText = Content;
            objNode.AppendChild(objElement);
        }    public void InsertElement(string MainNode, string Element, string Content)
        {
            //插入一个节点,不带属性。 
            XmlNode objNode = objXmlDoc.SelectSingleNode(MainNode);
            XmlElement objElement = objXmlDoc.CreateElement(Element);
            objElement.InnerText = Content;
            objNode.AppendChild(objElement);
        }    public void Save()
        {
            //保存文檔。 
            try
            {
                objXmlDoc.Save(strXmlFile);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            objXmlDoc = null;
        } 
       
    }
    这是一个XML操作类
    “把这十份里面的 <tcm:Data> 部分都抽取出来,重新整合到一个新的XML文件里面 ”的过程其实就是先用Xpath把你需要的选出来,然后使用InsertElement往一个空XML文件里添加。
    关于XPath的使用网上例子很多,google一下。
      

  3.   

    读<tcm:Data>节点.然后往一个新的xml文件里写
    具体的按7楼的那样