ReadNode() public method

public ReadNode ( XmlReader reader ) : XmlNode
reader XmlReader
return XmlNode
 public static XmlNode[] ReadNodes(XmlReader xmlReader)
 {
     if (xmlReader == null)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlReader");
     XmlDocument doc = new XmlDocument();
     List<XmlNode> nodeList = new List<XmlNode>();
     if (xmlReader.MoveToFirstAttribute())
     {
         do
         {
             if (IsValidAttribute(xmlReader))
             {
                 XmlNode node = doc.ReadNode(xmlReader);
                 if (node == null)
                     throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
                 nodeList.Add(node);
             }
         } while (xmlReader.MoveToNextAttribute());
     }
     xmlReader.MoveToElement();
     if (!xmlReader.IsEmptyElement)
     {
         int startDepth = xmlReader.Depth;
         xmlReader.Read();
         while (xmlReader.Depth > startDepth && xmlReader.NodeType != XmlNodeType.EndElement)
         {
             XmlNode node = doc.ReadNode(xmlReader);
             if (node == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
             nodeList.Add(node);
         }
     }
     return nodeList.ToArray();
 }
Esempio n. 2
0
        protected override void ExecuteTask()
        {
            string filename = XmlFile.FullName;
            Log(Level.Info, "Attempting to load XML document in file '{0}'.", filename );
            XmlDocument document = new XmlDocument();
            document.Load(filename);
            Log(Level.Info, "XML document in file '{0}' loaded successfully.", filename );

            XmlNodeList nodes = document.SelectNodes(XPath);
            if(null == nodes)
            {
                throw new BuildException(String.Format("Node not found by XPath '{0}'", XPath));
            }
            for (Int32 i = 0, c = nodes.Count, last = c - 1; i < c; i++)
            {
                XmlNode node = nodes[i];
                if (i == last && NewXml != null)
                {
                    Log(Level.Info, "Replacing last node with new XML: {0}", NewXml);
                    XmlNode newnode = document.ReadNode(new XmlTextReader(new StringReader(NewXml)));
                    node.ParentNode.ReplaceChild(newnode, node);
                }
                else
                {
                    node.ParentNode.RemoveChild(node);
                }
            }

            // if (null != NewNode) node.ParentNode.AppendChild(NewNode);

            Log(Level.Info, "Attempting to save XML document to '{0}'.", filename );
            document.Save(filename);
            Log(Level.Info, "XML document successfully saved to '{0}'.", filename );
        }
Esempio n. 3
0
        //   <node id="29568287" version="1" timestamp="2007-05-24T23:55:56Z" uid="7591" user="******" changeset="65544" lat="34.7661891" lon="-82.3672466">
        //      <tag k="created_by" v="YahooApplet 1.1"/>
        //   </node>
        private void HandleNodeRead(XmlReader reader)
        {
            var osmNode = new OSMNode();

            osmNode.ID  = Convert.ToInt64(reader.GetAttribute("id"));
            osmNode.Lat = Convert.ToDouble(reader.GetAttribute("lat"));
            osmNode.Lon = Convert.ToDouble(reader.GetAttribute("lon"));

            osmNodes.Add(osmNode.ID, osmNode);

            var     doc  = new System.Xml.XmlDocument();
            XmlNode node = doc.ReadNode(reader);

            foreach (XmlAttribute attr in node.Attributes)
            {
                osmNode.InnerAttributes.Add(attr.Name, attr.Value);
            }

            if (node.HasChildNodes)
            {
                var tags = node.SelectNodes("tag");
                foreach (XmlNode tag in tags)
                {
                    var key = tag.Attributes["k"].Value;
                    var val = tag.Attributes["v"].Value;
                    osmNode.Tags.Add(key, val);
                }
            }
        }
		public void DeleteWritingSystemId(string id)
		{
			var fileToBeWrittenTo = new TempFile();
			var reader = XmlReader.Create(_liftFilePath, CanonicalXmlSettings.CreateXmlReaderSettings());
			var writer = XmlWriter.Create(fileToBeWrittenTo.Path, CanonicalXmlSettings.CreateXmlWriterSettings());
			//System.Diagnostics.Process.Start(fileToBeWrittenTo.Path);
			try
			{
				bool readerMovedByXmlDocument = false;
				while (readerMovedByXmlDocument || reader.Read())
				{
					readerMovedByXmlDocument = false;
					var xmldoc = new XmlDocument();
					if (reader.NodeType == XmlNodeType.Element && reader.Name == "entry")
					{
						var entryFragment = xmldoc.ReadNode(reader);
						readerMovedByXmlDocument = true;
						var nodesWithLangId = entryFragment.SelectNodes(String.Format("//*[@lang='{0}']", id));
						if (nodesWithLangId != null)
						{
							foreach (XmlNode node in nodesWithLangId)
							{
								var parent = node.SelectSingleNode("parent::*");
								if (node.Name == "gloss")
								{
									parent.RemoveChild(node);
								}
								else
								{
									var siblingNodes =
										node.SelectNodes("following-sibling::form | preceding-sibling::form");
									if (siblingNodes.Count == 0)
									{
										var grandParent = parent.SelectSingleNode("parent::*");
										grandParent.RemoveChild(parent);
									}
									else
									{
										parent.RemoveChild(node);
									}
								}
							}
						}
						entryFragment.WriteTo(writer);
					}
					else
					{
						writer.WriteNodeShallow(reader);
					}
					//writer.Flush();
				}
			}
			finally
			{
				reader.Close();
				writer.Close();
			}
			File.Delete(_liftFilePath);
			fileToBeWrittenTo.MoveTo(_liftFilePath);
		}
Esempio n. 5
0
 public static XmlNode GetXmlRootNode(String fileName, String nodeName)
 {
     XmlDocument doc = new XmlDocument();
     XmlTextReader textReader = new XmlTextReader(fileName);
     XmlNode currNode = doc.ReadNode(textReader);
     while (currNode != null)
     {
         if (currNode.NodeType == XmlNodeType.Element)
         {
             if (currNode.Name.Equals(nodeName, StringComparison.OrdinalIgnoreCase))
                 return currNode;
         }
         currNode = doc.ReadNode(textReader);
     }
     return null;
 }
        public void ExtractData(string soapBody)
        {
            if (soapBody != String.Empty)
            {
                try
                {
                    XmlTextReader xtr = new XmlTextReader(new System.IO.StringReader(soapBody));
                    XmlDocument doc = new XmlDocument();
                    XmlNode node = doc.ReadNode(xtr);

                    while (xtr.Read())
                    {
                        if (xtr.IsStartElement())
                        {
                            // Get element name
                            switch (xtr.Name)
                            {
                                //extract session id
                                case "SessionId":
                                    if (xtr.Read())
                                    {
                                        sessionID = xtr.Value.Trim();
                                    }
                                    break;
                                //extract object's name
                                case "sObject":
                                    if (xtr["xsi:type"] != null)
                                    {
                                        string sObjectName = xtr["xsi:type"];
                                        if (sObjectName != null)
                                        {
                                            objectName = sObjectName.Split(new char[] { ':' })[1];
                                        }
                                    }
                                    break;
                                //extract notification id [note: salesforce can send a notification multiple times. it is, therefore, a good idea to keep track of this id.]
                                case "Id":
                                    if (xtr.Read())
                                    {
                                        notificationIDs.Add(xtr.Value.Trim());
                                    }
                                    break;
                                //extract record id
                                case "sf:Id":
                                    if (xtr.Read())
                                    {
                                        objectIDs.Add(xtr.Value.Trim());
                                    }
                                    break;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    //TODO: log exception
                }
            }
        }
Esempio n. 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// The main entry point
        /// </summary>
        /// ------------------------------------------------------------------------------------
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Creates manifest files so that exe can be run without COM " +
                    "needed to be registered in the registry.");
                Console.WriteLine();
                Console.WriteLine("Usage:");
                Console.WriteLine("regfreeApp <exename>");
                return;
            }

            string executable = args[0];
            if (!File.Exists(executable))
            {
                Console.WriteLine("File {0} does not exist", executable);
                return;
            }

            string manifestFile = executable + ".manifest";
            XmlDocument doc = new XmlDocument();
            doc.PreserveWhitespace = true;

            if (File.Exists(manifestFile))
            {
                using (XmlReader reader = new XmlTextReader(manifestFile))
                {
                    try
                    {
                        reader.MoveToContent();
                    }
                    catch (XmlException)
                    {
                    }
                    doc.ReadNode(reader);
                }
            }

            RegFreeCreator creator = new RegFreeCreator(doc, false);
            XmlElement root = creator.CreateExeInfo(executable);

            string directory = Path.GetDirectoryName(executable);
            if (directory.Length == 0)
                directory = Directory.GetCurrentDirectory();
            foreach (string fileName in Directory.GetFiles(directory, "*.dll"))
                creator.ProcessTypeLibrary(root, fileName);

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.OmitXmlDeclaration = false;
            settings.NewLineOnAttributes = false;
            settings.NewLineChars = Environment.NewLine;
            settings.Indent = true;
            settings.IndentChars = "\t";
            using (XmlWriter writer = XmlWriter.Create(manifestFile, settings))
            {
                doc.WriteContentTo(writer);
            }
        }
 protected virtual XmlElement DeserializeElementForDocument(XmlDocument ownerDocument, Stream source)
 {
     using (var xmlReader = XmlReader.Create(source))
     {
         var element = (XmlElement)ownerDocument.ReadNode(xmlReader);
         var elementForDoc = (XmlElement)ownerDocument.ImportNode(element, true);
         return elementForDoc;
     }
 }
Esempio n. 9
0
        //  <relation id = "1084743" version="2" timestamp="2015-05-30T03:46:23Z" changeset="31576221" uid="2311536" user="******">
        //  <member type = "way" ref="69127471" role="outer"/>
        //  <member type = "way" ref="69127440" role="inner"/>
        //  <tag k = "building" v="yes"/>
        //  <tag k = "type" v="multipolygon"/>
        //</relation>


        private void HandlRelationRead(XmlReader reader)
        {
            var osmRelation = new OSMRelation();

            osmRelation.ID = Convert.ToInt64(reader.GetAttribute("id"));

            var     doc  = new System.Xml.XmlDocument();
            XmlNode node = doc.ReadNode(reader);

            foreach (XmlAttribute attr in node.Attributes)
            {
                osmRelation.InnerAttributes.Add(attr.Name, attr.Value);
            }

            if (node.HasChildNodes)
            {
                var members = node.SelectNodes("member");
                foreach (XmlNode member in members)
                {
                    var relationType = member.Attributes["type"].Value;
                    var id           = Convert.ToInt64(member.Attributes["ref"].Value);
                    var role         = member.Attributes["role"].Value;
                    var osmMember    = new RelationMember();
                    osmMember.MemberType = relationType;
                    osmMember.Ref        = id;
                    osmMember.Role       = role;
                    osmRelation.Members.Add(osmMember);

                    if (relationType == "way")
                    {
                        if (osmWays.ContainsKey(id))
                        {
                            osmRelation.OSMWays.Add(osmWays[id]);
                        }
                    }
                }

                var tags = node.SelectNodes("tag");
                foreach (XmlNode tag in tags)
                {
                    var key = tag.Attributes["k"].Value;
                    var val = tag.Attributes["v"].Value;

                    osmRelation.Tags.Add(key, val);
                }
            }

            var bbox = new BBox();

            foreach (var way in osmRelation.OSMWays)
            {
                bbox = SpatialUtilities.BboxUnion(bbox, way.Bbox);
            }
            osmRelation.Bbox = bbox;
            osmRelation.SetCenter();
            osmRelations.Add(osmRelation.ID, osmRelation);
        }
        private bool TryProcessFeedStream(BufferingStreamReader responseStream)
        {
            bool isRssOrFeed = false;

            try
            {
                XmlReaderSettings readerSettings = GetSecureXmlReaderSettings();
                XmlReader reader = XmlReader.Create(responseStream, readerSettings);

                // See if the reader contained an "RSS" or "Feed" in the first 10 elements (RSS and Feed are normally 2 or 3)
                int readCount = 0;
                while ((readCount < 10) && reader.Read())
                {
                    if (String.Equals("rss", reader.Name, StringComparison.OrdinalIgnoreCase) ||
                        String.Equals("feed", reader.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        isRssOrFeed = true;
                        break;
                    }

                    readCount++;
                }

                if (isRssOrFeed)
                {
                    XmlDocument workingDocument = new XmlDocument();
                    // performing a Read() here to avoid rrechecking
                    // "rss" or "feed" items
                    reader.Read();
                    while (!reader.EOF)
                    {
                        // If node is Element and it's the 'Item' or 'Entry' node, emit that node.
                        if ((reader.NodeType == XmlNodeType.Element) &&
                            (string.Equals("Item", reader.Name, StringComparison.OrdinalIgnoreCase) ||
                             string.Equals("Entry", reader.Name, StringComparison.OrdinalIgnoreCase))
                           )
                        {
                            // this one will do reader.Read() internally
                            XmlNode result = workingDocument.ReadNode(reader);
                            WriteObject(result);
                        }
                        else
                        {
                            reader.Read();
                        }
                    }
                }
            }
            catch (XmlException) { }
            finally
            {
                responseStream.Seek(0, SeekOrigin.Begin);
            }

            return isRssOrFeed;
        }
 internal void ReadDataSourceExtraInformation(XmlTextReader xmlTextReader)
 {
     XmlDocument document = new XmlDocument();
     XmlNode newChild = document.ReadNode(xmlTextReader);
     document.AppendChild(newChild);
     if (this.serializer != null)
     {
         this.serializer.DeserializeBody((XmlElement) newChild, this);
     }
 }
 private static XmlElement DownCastToSurfaceElement(XElement element)
 {
     XNamespace ns = "http://www.opengis.net/gml/3.2";
     XmlDocument doc = new XmlDocument();
   
     element.Name = ns+ "Surface";         
     
     return doc.ReadNode(element.CreateReader()) as XmlElement;
    
 }
Esempio n. 13
0
        /// <summary>
        /// 判断是否为WIN7 以及32或64位
        /// </summary>
        /// <param name="imagex">imagex文件名,默认传imagex字段</param>
        /// <param name="wimfile">WIM文件路径</param>
        /// <returns>不是WIN7系统:0,Windows 7 STARTER(表示为32位系统镜像):1,Windows 7 HOMEBASIC(表示为64位系统镜像):2</returns>
        public static int Iswin7(string imagex, string wimfile)
        {
            ProcessManager.SyncCMD("\"" + WTGModel.applicationFilesPath + "\\" + imagex + "\"" + " /info \"" + wimfile + "\" /xml > " + "\"" + WTGModel.logPath + "\\wiminfo.xml\"");
            XmlDocument xml = new XmlDocument();

            System.Xml.XmlDocument   doc    = new System.Xml.XmlDocument();
            System.Xml.XmlNodeReader reader = null;

            string strFilename = WTGModel.logPath + "\\wiminfo.xml";

            if (!File.Exists(strFilename))
            {
                //MsgManager.getResString("Msg_wiminfoerror")
                //WIM文件信息获取失败\n将按WIN8系统安装
                Log.WriteLog("Iswin7.log", strFilename + "文件不存在");
                //MessageBox.Show(strFilename + MsgManager.getResString("Msg_wiminfoerror", MsgManager.ci));
                return(0);
            }
            try
            {
                doc.Load(strFilename);
                reader = new System.Xml.XmlNodeReader(doc);
                while (reader.Read())
                {
                    if (reader.IsStartElement("NAME"))
                    {
                        //从找到的这个依次往下读取节点
                        System.Xml.XmlNode aa = doc.ReadNode(reader);
                        if (aa.InnerText == "Windows 7 STARTER")
                        {
                            return(1);
                        }
                        else if (aa.InnerText == "Windows 7 HOMEBASIC")
                        {
                            return(2);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                Log.WriteLog("Iswin7.log", strFilename + "\n" + ex.ToString());
                //MessageBox.Show(strFilename + MsgManager.getResString("Msg_wiminfoerror", MsgManager.ci) + ex.ToString());
                return(0);
            }



            return(0);
        }
Esempio n. 14
0
        public IEnumerable <K> ReadStream <K>(string strUrl, params string[] nodes) where K : SerializeBase <K>
        {
            List <K>  retval     = new List <K>();
            string    uri        = "";
            string    name       = "";
            Hashtable attributes = new Hashtable();

            try
            {
                using (var reader = XmlReader.Create(strUrl))
                {
                    while (reader.Read())
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Element:
                            attributes = new Hashtable();
                            uri        = reader.NamespaceURI;
                            name       = reader.Name;
                            if (reader.HasAttributes)
                            {
                                for (int i = 0; i < reader.AttributeCount; i++)
                                {
                                    reader.MoveToAttribute(i);
                                    attributes.Add(reader.Name, reader.Value);
                                }
                            }
                            if (name == "PartInfo")
                            {
                                Console.WriteLine(reader.ReadInnerXml());
                                var     doc  = new System.Xml.XmlDocument();
                                XmlNode node = doc.ReadNode(reader);
                                doc.AppendChild(node);
                            }
                            //reader.Value
                            //StartElement(strURI, strName, strName, attributes);
                            break;

                        case XmlNodeType.EndElement:
                            name = reader.Name;
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            catch (XmlException e)
            {
                Console.WriteLine("error occured: " + e.Message);
            }
            return(retval);
        }
 private XmlElement ArrangeTransformElement(XmlDocument document, string xml)
 {
     using (var textReader = new StringReader(xml))
     {
         using (var xmlReader = new XmlTextReader(textReader))
         {
             var node = document.ReadNode(xmlReader);
             return (XmlElement)node;
         }
     }
 }
 public static System.Xml.XmlNode[] ReadNodes(XmlReader xmlReader)
 {
     if (xmlReader == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlReader");
     }
     XmlDocument document = new XmlDocument();
     List<System.Xml.XmlNode> list = new List<System.Xml.XmlNode>();
     if (xmlReader.MoveToFirstAttribute())
     {
         do
         {
             if (IsValidAttribute(xmlReader))
             {
                 System.Xml.XmlNode item = document.ReadNode(xmlReader);
                 if (item == null)
                 {
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("UnexpectedEndOfFile")));
                 }
                 list.Add(item);
             }
         }
         while (xmlReader.MoveToNextAttribute());
     }
     xmlReader.MoveToElement();
     if (!xmlReader.IsEmptyElement)
     {
         int depth = xmlReader.Depth;
         xmlReader.Read();
         while ((xmlReader.Depth > depth) && (xmlReader.NodeType != XmlNodeType.EndElement))
         {
             System.Xml.XmlNode node2 = document.ReadNode(xmlReader);
             if (node2 == null)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("UnexpectedEndOfFile")));
             }
             list.Add(node2);
         }
     }
     return list.ToArray();
 }
Esempio n. 17
0
 public Message OperationForBodyA(Message msg)
 {
     // create reply for this operation, wrapping the original request body
     XmlDocument responseBody = new XmlDocument();
     responseBody.AppendChild(responseBody.CreateElement("replyBodyA", "http://tempuri.org"));
     responseBody.DocumentElement.AppendChild(responseBody.ReadNode(msg.GetReaderAtBodyContents()));
     Message reply = Message.CreateMessage(
         msg.Version,
         null,
         new XmlNodeReader(responseBody.DocumentElement));
     return reply;
 }
Esempio n. 18
0
 public static bool Load(XmlTextReader reader, Report report)
 {
     var xmlDoc = new XmlDocument();
     XmlNode el;
     while ((el = xmlDoc.ReadNode(reader)) != null)
     {
         if (el.NodeType != XmlNodeType.Element)
             continue;
         Load((XmlElement)el, report);
         return true;
     }
     return false;
 }
Esempio n. 19
0
        /// <summary>
        /// Parse the constraint string to set the class properties.
        /// </summary>
        public override void ParseConstraintString()
        {
            XmlTextReader node = new XmlTextReader(ConstraintString,XmlNodeType.Element,null);
            XmlDocument doc = new XmlDocument();
            XmlNode xmlConstraint = doc.ReadNode(node);

            base.Name = xmlConstraint.Attributes["name"].Value;
            base.Property = xmlConstraint.Attributes["property"].Value;
            base.Operator = (ConstraintOperator)Enum.Parse(typeof(Klod.Validation.ConstraintOperator),xmlConstraint.Attributes["operator"].Value);
            base.TypeToValidate = Type.GetType(xmlConstraint.Attributes["typeToValidate"].Value);
            base.Value = xmlConstraint.Attributes["value"].Value;
            base.ValueType = Type.GetType(xmlConstraint.Attributes["valueType"].Value);
        }
Esempio n. 20
0
		public static XmlNode [] ReadNodes (XmlReader xmlReader)
		{
			if (xmlReader.NodeType != XmlNodeType.Element || xmlReader.IsEmptyElement)
				return new XmlNode [0];

			int depth = xmlReader.Depth;
			xmlReader.Read ();
			if (xmlReader.NodeType == XmlNodeType.EndElement)
				return new XmlNode [0];

			List<XmlNode> al = new List<XmlNode> ();
			XmlDocument doc = new XmlDocument ();
			while (xmlReader.Depth > depth & !xmlReader.EOF)
				al.Add (doc.ReadNode (xmlReader));
			return al.ToArray ();
		}
Esempio n. 21
0
      private void DataLoadModel_OnComplete(object sender, EventArgs e)
        {
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments = true;
            XmlElement reqElement = null;
            XmlDocument x = new XmlDocument();

            using (XmlReader reader = XmlReader.Create(this.DataLoadModel.FilePath, settings))
            {
                reader.MoveToContent();

                if (reader.Name == String.Empty)
                {
                    logger.Info(DataLoadConstants.STR_NODE_NOT_PRESENT);
                    return;                    
                }

                // Create root node and associate attributes
                reqElement = x.CreateElement(reader.Name);
                int i = 0;
                while (i < reader.AttributeCount && reader.HasAttributes)
                {
                    reader.MoveToAttribute(i);
                    reqElement.SetAttribute(reader.Name, reader.Value);
                    i++;
                }

                // Create request message with list of registration Ids
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == DataLoadConstants.ELEMENT_REGISTRATIONID)
                    {
                        XElement xelement = this.CreateVehicleInfoChildElement(reader);
                        XmlElement item = x.ReadNode(xelement.CreateReader()) as XmlElement;
                        if (item != null)
                        {
                            reqElement.AppendChild(item);
                        }
                    }
                }

                XmlElement response = this.InvokeXmphProcessData(reqElement);
            }
        }
Esempio n. 22
0
        public static bool AreXmlElementsEqual(string ours, string theirs)
        {
            StringReader osr = new StringReader(ours);
            XmlReader or = XmlReader.Create(osr);
            XmlDocument od = new XmlDocument();
            XmlNode on = od.ReadNode(or);
            on.Normalize();

            StringReader tsr = new StringReader(theirs);
            XmlReader tr = XmlReader.Create(tsr);
            XmlDocument td = new XmlDocument();
            XmlNode tn = td.ReadNode(tr);
            tn.Normalize();//doesn't do much

            //            StringBuilder builder = new StringBuilder();
            //            XmlWriter w = XmlWriter.Create(builder);

            return AreXmlElementsEqual(on, tn);
        }
Esempio n. 23
0
        private XmlDocument ReadXmlFragment (string elementName) {
            if (_Reader.IsEmptyElement)
                return null;

            var result = new XmlDocument();
            if (!_Reader.Read())
                return null;

            while (_Reader.NodeType != XmlNodeType.EndElement || _Reader.Name != elementName) {
                var node = result.ReadNode(_Reader);

                if (node != null)
                    result.AppendChild(node);
                else
                    throw new ArgumentException("Invalid XML fragment");
            }

            return result;
        }
 private XmlElement MakeXmlEnemyInstanceTemplate(XmlDocument doc)
 {
     XmlElement enemyInst = doc.CreateElement("EnemyInstance");
     enemyInst.SetAttribute("level", "0");
    
     XElement template = new XElement("EnemyInstance", new XAttribute("level", "0"),
                                         new XElement("Description", new XAttribute("value", "0")),
                                         new XElement("Classes"),
                                         new XElement("Stats", new XAttribute("HP", "1"), new XAttribute("MP", "0"), new XAttribute("SP", "0"), new XAttribute("Strength", "0"), new XAttribute("Vitality", "0"), new XAttribute("Magic", "0"), new XAttribute("Spirit", "0"), new XAttribute("Skill", "0"), new XAttribute("Speed", "0"), new XAttribute("Evasion", "0"), new XAttribute("MgEvasion", "0"), new XAttribute("Accuracy", "0"), new XAttribute("Luck", "0")),
                                         new XElement("StatusResistances"),
                                         new XElement("ElementalEffectiveness"),
                                         new XElement("LootTable"),
                                         new XElement("DropTable"),
                                         new XElement("AIScript"),
                                         new XElement("Flags"));            
     using (var xmlRead = template.CreateReader())
     {
         return (XmlElement)doc.ReadNode(xmlRead);
     }
 }
Esempio n. 25
0
        //<way id = "4526699" version="9" timestamp="2016-09-15T08:28:48Z" uid="1745400" user="******" changeset="42167009">
        //  <nd ref="28099395"/>
        //  <nd ref="1583440533"/>
        //  <nd ref="299356652"/>
        //  <nd ref="28099387"/>
        //  <nd ref="1583440406"/>
        //  <nd ref="28099388"/>
        //  <nd ref="28099389"/>
        //  <nd ref="28099390"/>
        //  <tag k = "highway" v="primary_link"/>
        //  <tag k = "oneway" v="yes"/>
        //</way>

        private void HandleWayRead(XmlReader reader)
        {
            var osmWay = new OSMWay();

            osmWay.ID = Convert.ToInt64(reader.GetAttribute("id"));

            var     doc  = new System.Xml.XmlDocument();
            XmlNode node = doc.ReadNode(reader);

            foreach (XmlAttribute attr in node.Attributes)
            {
                osmWay.InnerAttributes.Add(attr.Name, attr.Value);
            }

            if (node.HasChildNodes)
            {
                var nodeRefs = node.SelectNodes("nd");
                foreach (XmlNode osmNode in nodeRefs)
                {
                    var id = Convert.ToInt64(osmNode.Attributes["ref"].Value);
                    if (osmNodes.ContainsKey(id))
                    {
                        osmWay.NodeList.Add(osmNodes[id]);
                    }
                }


                var tags = node.SelectNodes("tag");
                foreach (XmlNode tag in tags)
                {
                    var key = tag.Attributes["k"].Value;
                    var val = tag.Attributes["v"].Value;
                    osmWay.Tags.Add(key, val);
                }
            }
            SpatialUtilities.SetBboxFor(osmWay);
            osmWay.SetCenter();
            osmWays.Add(osmWay.ID, osmWay);
        }
Esempio n. 26
0
 internal void ReadXDRSchema(XmlReader reader) {
     XmlDocument xdoc = new XmlDocument(); // we may need this to infer the schema
     XmlNode schNode = xdoc.ReadNode(reader);;
     //consume and ignore it - No support
 }
Esempio n. 27
0
        internal XmlReadMode ReadXml(XmlReader reader, XmlReadMode mode, bool denyResolving)
        {
            DataTable.RowDiffIdUsageSection rowDiffIdUsage = new DataTable.RowDiffIdUsageSection();
            try {
                bool fSchemaFound = false;
                bool fDataFound = false;
                bool fIsXdr = false;
                int iCurrentDepth = -1;
                XmlReadMode ret = mode;

                // Dev11 904428: prepare and cleanup rowDiffId hashtable
                rowDiffIdUsage.Prepare(this);

                if (reader == null)
                    return ret;

                bool originalEnforceConstraint  = false;
                if (this.DataSet != null) {
                    originalEnforceConstraint  = this.DataSet.EnforceConstraints;
                    this.DataSet.EnforceConstraints = false;
                }
                else {
                    originalEnforceConstraint  = this.EnforceConstraints;
                    this.EnforceConstraints = false;
                }

                if (reader is XmlTextReader)
                    ((XmlTextReader) reader).WhitespaceHandling = WhitespaceHandling.Significant;

                XmlDocument xdoc = new XmlDocument(); // we may need this to infer the schema

                if ((mode != XmlReadMode.Fragment) && (reader.NodeType == XmlNodeType.Element))
                    iCurrentDepth = reader.Depth;

                reader.MoveToContent();
                if (Columns.Count == 0) {
                    if (IsEmptyXml(reader)) {
                        reader.Read();
                        return ret;
                    }
                }

                XmlDataLoader xmlload = null;

                if (reader.NodeType == XmlNodeType.Element) {
                    XmlElement topNode = null;
                    if (mode == XmlReadMode.Fragment) {
                        xdoc.AppendChild(xdoc.CreateElement("ds_sqlXmlWraPPeR"));
                        topNode = xdoc.DocumentElement;
                    }
                    else { //handle the top node
                        if ((reader.LocalName == Keywords.DIFFGRAM) && (reader.NamespaceURI == Keywords.DFFNS)) {
                            if ((mode == XmlReadMode.DiffGram) || (mode == XmlReadMode.IgnoreSchema)) {
                                if (Columns.Count == 0) {
                                    if(reader.IsEmptyElement) {
                                        reader.Read();
                                        return XmlReadMode.DiffGram;
                                    }
                                    throw ExceptionBuilder.DataTableInferenceNotSupported();
                                }
                                this.ReadXmlDiffgram(reader);
                                // read the closing tag of the current element
                                ReadEndElement(reader);
                            }
                            else {
                                reader.Skip();
                            }
                            RestoreConstraint(originalEnforceConstraint);
                            return ret;
                        }

                        if (reader.LocalName == Keywords.XDR_SCHEMA && reader.NamespaceURI==Keywords.XDRNS) {
                            // load XDR schema and exit
                            if ((mode != XmlReadMode.IgnoreSchema) && (mode != XmlReadMode.InferSchema)) {
                                ReadXDRSchema(reader);
                            }
                            else {
                                reader.Skip();
                            }
                            RestoreConstraint(originalEnforceConstraint);
                            return ret; //since the top level element is a schema return
                        }

                        if (reader.LocalName == Keywords.XSD_SCHEMA && reader.NamespaceURI==Keywords.XSDNS) {
                            // load XSD schema and exit
                            if ((mode != XmlReadMode.IgnoreSchema) && (mode != XmlReadMode.InferSchema))  {
                                ReadXmlSchema(reader, denyResolving);
                            }
                            else
                                reader.Skip();
                            RestoreConstraint(originalEnforceConstraint);
                            return ret; //since the top level element is a schema return
                        }

                        if (reader.LocalName == Keywords.XSD_SCHEMA && reader.NamespaceURI.StartsWith(Keywords.XSD_NS_START, StringComparison.Ordinal))  {
                             if (this.DataSet != null) { // we should not throw for constraint, we already will throw for unsupported schema, so restore enforce cost, but not via property
                                 this.DataSet.RestoreEnforceConstraints(originalEnforceConstraint);
                             }
                             else {
                                this.enforceConstraints = originalEnforceConstraint;
                            }
                            throw ExceptionBuilder.DataSetUnsupportedSchema(Keywords.XSDNS);
                        }

                        // now either the top level node is a table and we load it through dataReader...
                        // ... or backup the top node and all its attributes
                        topNode = xdoc.CreateElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                        if (reader.HasAttributes) {
                            int attrCount = reader.AttributeCount;
                            for (int i=0;i<attrCount;i++) {
                                reader.MoveToAttribute(i);
                                if (reader.NamespaceURI.Equals(Keywords.XSD_XMLNS_NS))
                                    topNode.SetAttribute(reader.Name, reader.GetAttribute(i));
                                else {
                                    XmlAttribute attr = topNode.SetAttributeNode(reader.LocalName, reader.NamespaceURI);
                                    attr.Prefix = reader.Prefix;
                                    attr.Value = reader.GetAttribute(i);
                                }
                            }
                        }
                        reader.Read();
                    }

                    while(MoveToElement(reader, iCurrentDepth)) {

                        if (reader.LocalName == Keywords.XDR_SCHEMA && reader.NamespaceURI==Keywords.XDRNS) {
                            // load XDR schema
                       	    if (!fSchemaFound && !fDataFound && (mode != XmlReadMode.IgnoreSchema) && (mode != XmlReadMode.InferSchema))  {
                                ReadXDRSchema(reader);
                                fSchemaFound = true;
                                fIsXdr = true;
                            }
                            else {
                                reader.Skip();
                            }
                            continue;
                        }

                        if (reader.LocalName == Keywords.XSD_SCHEMA && reader.NamespaceURI==Keywords.XSDNS) {
                        // load XSD schema and exit
                            if ((mode != XmlReadMode.IgnoreSchema) && (mode != XmlReadMode.InferSchema))  {
                                ReadXmlSchema(reader, denyResolving);
                                fSchemaFound = true;
                            }
                            else {
                                reader.Skip();
                            }
                            continue;
                        }

                        if ((reader.LocalName == Keywords.DIFFGRAM) && (reader.NamespaceURI == Keywords.DFFNS)) {
                            if ((mode == XmlReadMode.DiffGram) || (mode == XmlReadMode.IgnoreSchema)) {
                                if (Columns.Count == 0) {
                                    if(reader.IsEmptyElement) {
                                        reader.Read();
                                        return XmlReadMode.DiffGram;
                                    }
                                    throw ExceptionBuilder.DataTableInferenceNotSupported();
                                }
                                this.ReadXmlDiffgram(reader);
                                ret = XmlReadMode.DiffGram;
                            }
                            else {
                                reader.Skip();
                            }
                            continue;
                        }

                        if (reader.LocalName == Keywords.XSD_SCHEMA && reader.NamespaceURI.StartsWith(Keywords.XSD_NS_START, StringComparison.Ordinal))  {
                            if (this.DataSet != null) { // we should not throw for constraint, we already will throw for unsupported schema, so restore enforce cost, but not via property
                                 this.DataSet.RestoreEnforceConstraints(originalEnforceConstraint);
                            }
                            else {
                                this.enforceConstraints = originalEnforceConstraint;
                            }
                            throw ExceptionBuilder.DataSetUnsupportedSchema(Keywords.XSDNS);
                        }

                        if (mode == XmlReadMode.DiffGram) {
                            reader.Skip();
                            continue; // we do not read data in diffgram mode
                        }

                        // if we are here we found some data
                        fDataFound = true;

                        if (mode == XmlReadMode.InferSchema) { //save the node in DOM until the end;
                            XmlNode node = xdoc.ReadNode(reader);
                            topNode.AppendChild(node);
                        }
                        else {
                            if (Columns.Count == 0) {
                                throw ExceptionBuilder.DataTableInferenceNotSupported();
                            }
                            if (xmlload == null)
                                xmlload = new XmlDataLoader(this, fIsXdr, topNode,  mode == XmlReadMode.IgnoreSchema);
                            xmlload.LoadData(reader);
                        }
                    } //end of the while

                    // read the closing tag of the current element
                    ReadEndElement(reader);

                    // now top node contains the data part
                    xdoc.AppendChild(topNode);

                    if (xmlload == null)
                        xmlload = new XmlDataLoader(this, fIsXdr, mode == XmlReadMode.IgnoreSchema);

                    if (mode == XmlReadMode.DiffGram) {
                        // we already got the diffs through XmlReader interface
                        RestoreConstraint(originalEnforceConstraint);
                        return ret;
                    }
    //todo
                    // Load Data
                    if (mode == XmlReadMode.InferSchema) {
                        if (Columns.Count == 0) {
                            throw ExceptionBuilder.DataTableInferenceNotSupported();
                        }

    // [....]                    xmlload.InferSchema(xdoc, null);
    // [....]                    xmlload.LoadData(xdoc);
                    }
                }
                RestoreConstraint(originalEnforceConstraint);

                return ret;
            }
            finally {
                // Dev11 904428: prepare and cleanup rowDiffId hashtable
                rowDiffIdUsage.Cleanup();
            }
        }
Esempio n. 28
0
        internal XmlReadMode ReadXml(XmlReader reader, bool denyResolving)
        {
            IntPtr hscp;
            Bid.ScopeEnter(out hscp, "<ds.DataTable.ReadXml|INFO> %d#, denyResolving=%d{bool}\n", ObjectID, denyResolving);
            try {

              DataTable.RowDiffIdUsageSection rowDiffIdUsage = new DataTable.RowDiffIdUsageSection();
              try {
                bool fDataFound = false;
                bool fSchemaFound = false;
                bool fDiffsFound = false;
                bool fIsXdr = false;
                int iCurrentDepth = -1;
                XmlReadMode ret = XmlReadMode.Auto;

                // clear the hashtable to avoid conflicts between diffgrams, SqlHotFix 782
                rowDiffIdUsage.Prepare(this);

                if (reader == null)
                    return ret;
                bool originalEnforceConstraint = false;
                if (this.DataSet != null) {
                    originalEnforceConstraint = this.DataSet.EnforceConstraints;
                    this.DataSet.EnforceConstraints = false;
                }
                else {
                    originalEnforceConstraint = this.EnforceConstraints;
                    this.EnforceConstraints = false;
                }

                if (reader is XmlTextReader)
                    ((XmlTextReader) reader).WhitespaceHandling = WhitespaceHandling.Significant;

                XmlDocument xdoc = new XmlDocument(); // we may need this to infer the schema
                XmlDataLoader xmlload = null;


                reader.MoveToContent();
                if (Columns.Count == 0) {
                    if (IsEmptyXml(reader)) {
                        reader.Read();
                        return ret;
                    }
                }

                if (reader.NodeType == XmlNodeType.Element) {
                    iCurrentDepth = reader.Depth;

                    if ((reader.LocalName == Keywords.DIFFGRAM) && (reader.NamespaceURI == Keywords.DFFNS)) {
                        if (Columns.Count == 0) {
                            if (reader.IsEmptyElement) {
                                reader.Read();
                                return XmlReadMode.DiffGram;
                            }
                            throw ExceptionBuilder.DataTableInferenceNotSupported();
                        }
                        this.ReadXmlDiffgram(reader);
                        // read the closing tag of the current element
                        ReadEndElement(reader);

                        RestoreConstraint(originalEnforceConstraint);
                        return XmlReadMode.DiffGram;
                    }

                    // if reader points to the schema load it
                    if (reader.LocalName == Keywords.XDR_SCHEMA && reader.NamespaceURI==Keywords.XDRNS) {
                        // load XDR schema and exit
                        ReadXDRSchema(reader);

                        RestoreConstraint(originalEnforceConstraint);
                        return XmlReadMode.ReadSchema; //since the top level element is a schema return
                    }

                    if (reader.LocalName == Keywords.XSD_SCHEMA && reader.NamespaceURI==Keywords.XSDNS) {
                        // load XSD schema and exit
                        ReadXmlSchema(reader, denyResolving);
                        RestoreConstraint(originalEnforceConstraint);
                        return XmlReadMode.ReadSchema; //since the top level element is a schema return
                    }

                    if (reader.LocalName == Keywords.XSD_SCHEMA && reader.NamespaceURI.StartsWith(Keywords.XSD_NS_START, StringComparison.Ordinal)) {
                        if (this.DataSet != null) { // we should not throw for constraint, we already will throw for unsupported schema, so restore enforce cost, but not via property
                            this.DataSet.RestoreEnforceConstraints(originalEnforceConstraint);
                        }
                        else {
                            this.enforceConstraints = originalEnforceConstraint;
                        }

                        throw ExceptionBuilder.DataSetUnsupportedSchema(Keywords.XSDNS);
                    }

                    // now either the top level node is a table and we load it through dataReader...

                    // ... or backup the top node and all its attributes because we may need to InferSchema
                    XmlElement topNode = xdoc.CreateElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                    if (reader.HasAttributes) {
                        int attrCount = reader.AttributeCount;
                        for (int i=0;i<attrCount;i++) {
                            reader.MoveToAttribute(i);
                            if (reader.NamespaceURI.Equals(Keywords.XSD_XMLNS_NS))
                                topNode.SetAttribute(reader.Name, reader.GetAttribute(i));
                            else {
                                XmlAttribute attr = topNode.SetAttributeNode(reader.LocalName, reader.NamespaceURI);
                                attr.Prefix = reader.Prefix;
                                attr.Value = reader.GetAttribute(i);
                            }
                        }
                    }
                    reader.Read();

                    while(MoveToElement(reader, iCurrentDepth)) {

                        if ((reader.LocalName == Keywords.DIFFGRAM) && (reader.NamespaceURI == Keywords.DFFNS)) {
                            this.ReadXmlDiffgram(reader);
                            // read the closing tag of the current element
                            ReadEndElement(reader);
                            RestoreConstraint(originalEnforceConstraint);
                            return XmlReadMode.DiffGram;
                        }

                        // if reader points to the schema load it...


                        if (!fSchemaFound && !fDataFound && reader.LocalName == Keywords.XDR_SCHEMA && reader.NamespaceURI==Keywords.XDRNS) {
                            // load XDR schema and exit
                            ReadXDRSchema(reader);
                            fSchemaFound = true;
                            fIsXdr = true;
                            continue;
                        }

                        if (reader.LocalName == Keywords.XSD_SCHEMA && reader.NamespaceURI==Keywords.XSDNS) {
                            // load XSD schema and exit
                            ReadXmlSchema(reader, denyResolving);
                            fSchemaFound = true;
                            continue;
                        }

                        if (reader.LocalName == Keywords.XSD_SCHEMA && reader.NamespaceURI.StartsWith(Keywords.XSD_NS_START, StringComparison.Ordinal))  {
                            if (this.DataSet != null) { // we should not throw for constraint, we already will throw for unsupported schema, so restore enforce cost, but not via property
                                this.DataSet.RestoreEnforceConstraints(originalEnforceConstraint);
                            }
                            else {
                                this.enforceConstraints = originalEnforceConstraint;
                            }
                            throw ExceptionBuilder.DataSetUnsupportedSchema(Keywords.XSDNS);
                        }

                        if ((reader.LocalName == Keywords.DIFFGRAM) && (reader.NamespaceURI == Keywords.DFFNS)) {
                            this.ReadXmlDiffgram(reader);
                            fDiffsFound = true;
                            ret = XmlReadMode.DiffGram;
                        }
                        else {
                            // we found data here
                            fDataFound = true;

                            if (!fSchemaFound && Columns.Count == 0) {
                                XmlNode node = xdoc.ReadNode(reader);
                                topNode.AppendChild(node);
                            }
                            else {
                                if (xmlload == null)
                                    xmlload = new XmlDataLoader(this, fIsXdr, topNode, false);
                                xmlload.LoadData(reader);
                                if (fSchemaFound)
                                    ret = XmlReadMode.ReadSchema;
                                else
                                    ret = XmlReadMode.IgnoreSchema;
                            }
                        }

                    }
                    // read the closing tag of the current element
                    ReadEndElement(reader);

                    // now top node contains the data part
                    xdoc.AppendChild(topNode);

                    if (!fSchemaFound && Columns.Count == 0) {
                        if (IsEmptyXml(reader)) {
                            reader.Read();
                            return ret;
                        }
                        throw ExceptionBuilder.DataTableInferenceNotSupported();
                    }

                    if (xmlload == null)
                        xmlload = new XmlDataLoader(this, fIsXdr, false);

                    // so we InferSchema
                    if (!fDiffsFound) {// we need to add support for inference here
                    }
                }
                RestoreConstraint(originalEnforceConstraint);
                return ret;
              }
              finally {
                rowDiffIdUsage.Cleanup();
              }
            }
            finally{
                Bid.ScopeLeave(ref hscp);
            }
        }
Esempio n. 29
0
		protected XmlDocument ReadXmlDocument (bool wrapped)
		{
			readCount++;

			if (wrapped)
				reader.ReadStartElement ();
			reader.MoveToContent ();
			XmlDocument doc = new XmlDocument (reader.NameTable);
			XmlNode node = doc.ReadNode (reader);
			doc.AppendChild (node);
			
			if (wrapped)
				reader.ReadEndElement ();
				
			return doc;
		}
Esempio n. 30
0
        /// <summary>
        /// Parse a localization file from an XML format.
        /// </summary>
        /// <param name="document">XmlDocument where the localization file is persisted.</param>
        /// <param name="tableDefinitions">Collection containing TableDefinitions to use when parsing the localization file.</param>
        /// <returns>The parsed localization.</returns>
        internal static Localization Parse(XmlReader reader, TableDefinitionCollection tableDefinitions)
        {
            XmlDocument document = new XmlDocument();
            reader.MoveToContent();
            XmlNode node = document.ReadNode(reader);
            document.AppendChild(node);

            Localization localization = new Localization();
            localization.tableDefinitions = tableDefinitions;
            localization.Parse(document);

            return localization;
        }
Esempio n. 31
0
 private static XmlNode CreateNode(string data)
 {
     using (var stringReader = new StringReader(data))
     using (var xmlReader = XmlReader.Create(stringReader))
     {
         var xmlDocument = new XmlDocument();
         var xmlNode = xmlDocument.ReadNode(xmlReader);
         xmlNode.Normalize();
         return xmlNode;
     }
 }
Esempio n. 32
0
        private void CreateXmlDocument()
        {
            var xml = new XmlDocument();
            xml.AppendChild(xml.CreateXmlDeclaration("1.0", null, null));

            var responseElement = xml.CreateElement("saml2p", "Response", Saml2Namespaces.Saml2PName);

            if (DestinationUrl != null)
            {
                responseElement.SetAttributeNode("Destination", "").Value = DestinationUrl.ToString();
            }

            responseElement.SetAttributeNode("ID", "").Value = id.Value;
            responseElement.SetAttributeNode("Version", "").Value = "2.0";
            responseElement.SetAttributeNode("IssueInstant", "").Value =
                DateTime.UtcNow.ToSaml2DateTimeString();
            if (InResponseTo != null)
            {
                responseElement.SetAttributeNode("InResponseTo", "").Value = InResponseTo.Value;
            }
            xml.AppendChild(responseElement);

            var issuerElement = xml.CreateElement("saml2", "Issuer", Saml2Namespaces.Saml2Name);
            issuerElement.InnerText = issuer.Id;
            responseElement.AppendChild(issuerElement);

            var statusElement = xml.CreateElement("saml2p", "Status", Saml2Namespaces.Saml2PName);
            var statusCodeElement = xml.CreateElement("saml2p", "StatusCode", Saml2Namespaces.Saml2PName);
            statusCodeElement.SetAttributeNode("Value", "").Value = StatusCodeHelper.FromCode(Status);
            statusElement.AppendChild(statusCodeElement);
            responseElement.AppendChild(statusElement);

            foreach (var ci in claimsIdentities)
            {
                responseElement.AppendChild(xml.ReadNode(
                    ci.ToSaml2Assertion(issuer).ToXElement().CreateReader()));
            }

            xmlDocument = xml;

            xml.Sign(issuerCertificate);
        }
Esempio n. 33
0
 protected override bool OnDeserializeUnrecognizedElement(string elementName, XmlReader reader)
 {
     XmlDocument doc = new XmlDocument();
     SectionData = doc.ReadNode(reader);
     return SectionData != null;
 }
Esempio n. 34
0
			public void ReadXml (XmlReader r)
			{
				r.MoveToContent ();
				XmlDocument doc = new XmlDocument ();
				data = new KeyInfoX509Data ();
				data.LoadXml (doc.ReadNode (r) as XmlElement);
			}
Esempio n. 35
0
 /// <summary>
 /// Reads XML from the configuration file.
 /// </summary>
 /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> that reads from the configuration file.</param>
 /// <param name="serializeCollectionKey">true to serialize only the collection key properties; otherwise, false.</param>
 protected override void DeserializeSection(XmlReader reader)
 {
     XmlDocument xd = new XmlDocument();
     _Node = xd.ReadNode(reader);
     if (_Node.Attributes["file"] != null)
     {
         FileInfo fi = new FileInfo(Path.Combine(Path.GetDirectoryName(this.CurrentConfiguration.FilePath), _Node.Attributes["file"].Value));
         if (fi.Exists)
         {
             _OriginalNode = Node;
             var xdr = new XmlDocument();
             if (_Node.Attributes["protected"] != null && _Node.Attributes["protected"].Value.ToLower() == "true")
             {
                 SatelliteFileIsProtected = true;
                 xdr.LoadXml(Encoding.UTF8.GetString(ProtectedData.Unprotect(File.ReadAllBytes(fi.FullName), Encoding.UTF8.GetBytes(_Node.Name), DataProtectionScope.LocalMachine)));
             }
             else
             {
                 SatelliteFileIsProtected = false;
                 xdr.Load(fi.FullName);
             }
             _Node = xdr.DocumentElement;
         }
     }
 }