示例#1
0
        /// <summary>
        /// Create the xml document within the xml file.
        /// </summary>
        /// <param name="item">The item containing the xml nodes to write.</param>
        /// <returns>True if the xml was saved; else false</returns>
        public virtual XDocument CreateDocument(TransformXmlModel item)
        {
            // Create the top level xml document
            // and save the document to the xml file
            XDocument xDoc = new XDocument(
                new XDeclaration(item.Version, item.Encoding, item.Standalone),
                new XElement(item.RootElementName, item.Nodes));

            // Return true if at this point.
            return(xDoc);
        }
示例#2
0
        /// <summary>
        /// Create the xml document within the xml file.
        /// </summary>
        /// <param name="item">The item containing the xml nodes to write.</param>
        /// <param name="xmlFilePath">The file name to write to.</param>
        /// <returns>True if the xml was saved; else false</returns>
        public virtual bool CreateDocument(TransformXmlModel item, string xmlFilePath)
        {
            // If the directory does not exist then create it.
            if (!Directory.Exists(System.IO.Path.GetDirectoryName(xmlFilePath)))
            {
                Directory.CreateDirectory(System.IO.Path.GetDirectoryName(xmlFilePath));
            }

            // Create the top level xml document
            // and save the document to the xml file
            XDocument xDoc = new XDocument(
                new XDeclaration(item.Version, item.Encoding, item.Standalone),
                new XElement(item.RootElementName, item.Nodes));

            xDoc.Save(xmlFilePath);

            // Return true if at this point.
            return(true);
        }