예제 #1
0
        public void SetDTDLocation(string dtdLocation)
        {
            System.Xml.XmlDocument doc = (System.Xml.XmlDocument)Node;
            string publicId            = null;
            string internalSubset      = null;

            if (doc.DocumentElement == null)
            {
                throw new System.InvalidOperationException("SetDTDLocation requires a root element.");
            }
            if (doc.DocumentType != null)
            {
                publicId       = doc.DocumentType.PublicId;
                internalSubset = doc.DocumentType.InternalSubset;

                doc.RemoveChild(doc.DocumentType);
            }
            doc.InsertBefore(doc.DocumentElement, doc.CreateDocumentType(doc.DocumentElement.Name, publicId, dtdLocation, internalSubset));
        }
예제 #2
0
        /// <summary>
        /// 保存XML分析结果
        /// </summary>
        /// <param name="xml"></param>
        public void SaveAnalyseResult(System.Xml.XmlDocument xml)
        {
            if (xml.DocumentElement != null)
            {
                xml.RemoveChild(xml.DocumentElement);
            }
            xml.AppendChild(xml.CreateElement("project"));
            xml.DocumentElement.SetAttribute("filename", this.projectFileName);
            xml.DocumentElement.SetAttribute("tickcount", this.tick.ToString());
            int iCount = 0;

            foreach (FileCollection mResults in results)
            {
                iCount++;
                System.Xml.XmlElement myResultsElement = xml.CreateElement("results");
                xml.DocumentElement.AppendChild(myResultsElement);
                myResultsElement.SetAttribute("time", mResults.Time);
                if (iCount == results.Count)
                {
                    myResultsElement.SetAttribute("last", "1");
                }
                foreach (FileEntity item in mResults)
                {
                    if (item.Analysed)
                    {
                        System.Xml.XmlElement myElement = xml.CreateElement("result");
                        myResultsElement.AppendChild(myElement);
                        myElement.SetAttribute("filename", item.FileName);
                        myElement.SetAttribute("filesize", item.FileSize.ToString());
                        myElement.SetAttribute("linecount", item.LineCount.ToString());
                        myElement.SetAttribute("codecount", item.CodeCount.ToString());
                        myElement.SetAttribute("commentcount", item.CommentCount.ToString());
                        myElement.SetAttribute("blankcount", item.BlankCount.ToString());
                        myElement.SetAttribute("charcount", item.CharCount.ToString());
                        myElement.SetAttribute("time", item.Time.ToString());
                    }
                }
            }
        }
예제 #3
0
파일: asx.cs 프로젝트: CarverLab/Oyster
        public void Write(string Filename)
        {
            //System.Xml.XmlTextWriter tw = new System.Xml.XmlTextWriter(TempFile,System.Text.Encoding.UTF8);
            System.IO.TextWriter tw = System.IO.File.CreateText(Filename);
            //			tw.Formatting = System.Xml.Formatting.Indented;
            base.Serialize(tw,m_asx);
            tw.Close();

            // now load this bugger up and get rid or all the junk that WMP can't parse
            System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
            xmld.Load(Filename);
            if (xmld.FirstChild.NodeType == System.Xml.XmlNodeType.XmlDeclaration)
            {
                xmld.RemoveChild(xmld.FirstChild);
            }
            xmld.DocumentElement.RemoveAttribute("xmlns:xsd");
            xmld.DocumentElement.RemoveAttribute("xmlns:xsi");
            // delete the temp file
            System.IO.FileInfo fi = new System.IO.FileInfo(Filename);
            System.IO.File.Delete(fi.FullName);
            xmld.Save(Filename);
        }