ParseFromXmlNode() public method

public ParseFromXmlNode ( XmlNode node ) : void
node System.Xml.XmlNode
return void
示例#1
0
        /// <summary>
        /// Opens from file.
        /// </summary>
        /// <param name='fileName'>
        /// File name.
        /// </param>
        public bool OpenFromFile(string fileName)
        {
            try
            {
                if (!File.Exists(fileName))
                {
                    return(false);
                }

                FileName = fileName;
                var fi = new System.IO.FileInfo(fileName);
                FileSize = fi.Length;

                Tracks.Clear();

                TargetContainer = MediaInfoBase.DetectContainerByExt(fileName);

                var mediaInfoXML = SupportMethods.ExecuteAndReturnOutput(MediaConvertGUIConfiguration.MediaInfoPath, "-f --Output=XML \"" + fileName + "\"");
                RawMediaInfoOutput = mediaInfoXML;

                var xmlDoc = new System.Xml.XmlDocument();
                xmlDoc.LoadXml(mediaInfoXML);

                var nodes = xmlDoc.SelectNodes("Mediainfo/File/track");
                foreach (XmlNode node in nodes)
                {
                    var track = new TrackInfo();
                    track.ParseFromXmlNode(node);
                    Tracks.Add(track);
                }

                return(true);
            } catch (Exception ex)
            {
                Console.WriteLine("Error:" + ex.ToString());
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// Opens from file.
        /// </summary>
        /// <param name='fileName'>
        /// File name.
        /// </param>
        public bool OpenFromFile(string fileName)
        {
            try
            {
                if (!File.Exists(fileName))
                    return false;

                FileName = fileName;
                var fi = new System.IO.FileInfo(fileName);
                FileSize = fi.Length;

                Tracks.Clear();

                TargetContainer = MediaInfoBase.DetectContainerByExt(fileName);

                var mediaInfoXML = SupportMethods.ExecuteAndReturnOutput(MediaConvertGUIConfiguration.MediaInfoPath,"-f --Output=XML \"" + fileName + "\"");
                RawMediaInfoOutput = mediaInfoXML;

                var xmlDoc = new System.Xml.XmlDocument();
                xmlDoc.LoadXml(mediaInfoXML);

                 var nodes =  xmlDoc.SelectNodes("Mediainfo/File/track");
                foreach (XmlNode node in nodes)
                {
                    var track = new TrackInfo();
                    track.ParseFromXmlNode(node);
                    Tracks.Add(track);
                }

                return true;

            } catch (Exception ex)
            {
                Console.WriteLine ("Error:"+ex.ToString());
                return false;
            }
        }