C# (CSharp) Class System.Xml. XmlNode Code Examples

C# (CSharp) System.Xml.XmlNode - 30 examples found. These are the top rated real world C# (CSharp) examples of class System.Xml.XmlNode extracted from open source projects. You can rate examples to help us improve the quality of examples
Inheritance: ICloneable, IEnumerable, IXPathNavigable
Example #1
0
 public static void SetAttribute( XmlNode node, string attributeName, string attributeValue )
 {
     if ( node.Attributes[ attributeName ] != null )
         node.Attributes[ attributeName ].Value = attributeValue ;
     else
         node.Attributes.Append( CreateAttribute( node.OwnerDocument, attributeName, attributeValue ) ) ;
 }
Example #2
0
	internal XmlAttributeCollection (XmlNode parent) : base (parent)
	{
		ownerElement = parent as XmlElement;
		ownerDocument = parent.OwnerDocument;
		if(ownerElement == null)
			throw new XmlException ("invalid construction for XmlAttributeCollection.");
	}
        public virtual object Create(object parent, object configContext, XmlNode section)
        {
            if (section == null)
                throw new ArgumentNullException("section");

            IList list = CreateList(parent);

            string itemName = ElementName;

            foreach (XmlNode childNode in section.ChildNodes)
            {
                if (childNode.NodeType == XmlNodeType.Comment ||
                    childNode.NodeType == XmlNodeType.Whitespace)
                {
                    continue;
                }

                if (childNode.NodeType != XmlNodeType.Element)
                {
                    throw new ConfigurationErrorsException(string.Format("Unexpected type of node ({0}) in configuration.", 
                        childNode.NodeType.ToString()), childNode);
                }

                if (childNode.Name != itemName)
                {
                    throw new ConfigurationErrorsException(string.Format("Element <{0}> is not valid here in configuration. Use <{1}> elements only.", 
                        childNode.Name, itemName), childNode);
                }

                list.Add(GetItem((XmlElement) childNode));
            }
            
            return list;
        }
Example #4
0
	public static string GetDisplayName (XmlNode type)
	{
		if (type.Attributes ["DisplayName"] != null) {
			return type.Attributes ["DisplayName"].Value;
		}
		return type.Attributes ["Name"].Value;
	}
        List<ParameterValue> _Items; // list of ParameterValue

        #endregion Fields

        #region Constructors

        internal ParameterValues(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            ParameterValue pv;
            _Items = new List<ParameterValue>();
            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                switch (xNodeLoop.Name)
                {
                    case "ParameterValue":
                        pv = new ParameterValue(r, this, xNodeLoop);
                        break;
                    default:
                        pv=null;		// don't know what this is
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown ParameterValues element '" + xNodeLoop.Name + "' ignored.");
                        break;
                }
                if (pv != null)
                    _Items.Add(pv);
            }

            if (_Items.Count == 0)
                OwnerReport.rl.LogError(8, "For ParameterValues at least one ParameterValue is required.");
            else
                _Items.TrimExcess();
        }
Example #6
0
	public APIVariable(APIPage InParent, XmlNode InNode)
		: base(InParent, InNode.SelectSingleNode("name").InnerText)
	{
		Node = InNode;
		Protection = ParseProtection(Node);
		AddRefLink(Node.Attributes["id"].InnerText, this);
	}
Example #7
0
        public void AddNodeArgumentsRecursive(XmlNode node, string subName, Dictionary<string, string> inputDic, string inputType, bool recursive)
        {
            if (node == null)
            {
                return;
            }

            foreach (XmlAttribute attr in node.Attributes)
            {
                string key = attr.LocalName;
                if (subName != "")
                {
                    key = subName + "." + attr.LocalName;
                }
                AddToArgDic(inputDic, key, attr.Value, inputType);
            }
            foreach (XmlNode childNode in node.ChildNodes)
            {
                string childName = childNode.LocalName;
                if (childNode.NodeType == XmlNodeType.Text)
                {
                    AddToArgDic(inputDic, subName, childNode.Value, inputType);
                }
                if (childNode.NodeType == XmlNodeType.Element && recursive)
                {
                    if (subName != "")
                    {
                        childName = subName + "." + childName;
                    }
                    AddNodeArgumentsRecursive(childNode, childName, inputDic, inputType, true);
                }
            }
        }
		/// <summary>
		/// Get protected and user-stored dictionary configurations to load into the dialog.
		/// Tests will override this to load the manager in their own fashion.
		/// </summary>
		private void LoadDataFromInventory(XmlNode current)
		{
			// Tuples are <uniqueCode, dispName, IsProtected>
			var configList = new List<Tuple<string, string, bool>>();

			// put them in configList and feed them into the Manager's dictionary.
			foreach (var xnView in m_originalViewConfigNodes)
			{
				var sLabel = XmlUtils.GetManditoryAttributeValue(xnView, "label");
				var sLayout = XmlUtils.GetManditoryAttributeValue(xnView, "layout");
				var fProtected = !sLayout.Contains(Inventory.kcMarkLayoutCopy);
				configList.Add(new Tuple<string, string, bool>(sLayout, sLabel, fProtected));
			}

			LoadInternalDictionary(configList);

			var sLayoutCurrent = XmlUtils.GetManditoryAttributeValue(current, "layout");
			m_originalView = sLayoutCurrent;
			m_currentView = m_originalView;

			if (m_configList.Count == 0)
				return;

			// Now set up the actual dialog's contents
			RefreshView();
		}
Example #9
0
        public string DownloadLrc(string singer, string title)
        {
            this.currentSong = null;
            XmlDocument xml = SearchLrc(singer, title);
            string retStr = "û���ҵ��ø��";
            if (xml == null)
                return retStr;

            XmlNodeList list = xml.SelectNodes("/result/lrc");
            if (list.Count > 0) {
                this.OnSelectSong(list);
                if (this.currentSong == null)
                    this.currentSong = list[0];
            } else if (list.Count == 1) {
                this.currentSong = list[0];
            } else {
                return retStr;
            }
            if (this.currentSong == null)
                return retStr;

            XmlNode node = this.currentSong;
            int lrcId = -1;
            if (node != null && node.Attributes != null && node.Attributes["id"] != null) {
                string sLrcId = node.Attributes["id"].Value;
                if (int.TryParse(sLrcId, out lrcId)) {
                    string xSinger = node.Attributes["artist"].Value;
                    string xTitle = node.Attributes["title"].Value;
                    retStr = RequestALink(string.Format(DownloadPath, lrcId,
                        EncodeHelper.CreateQianQianCode(xSinger, xTitle, lrcId)));
                }
            }
            return retStr;
        }
 public ClearQueue(XmlNode xmlNode)
 : base(xmlNode)
 {
     XmlNode actionTypeNode = xmlNode.SelectSingleNode("actionType");
     
     if (actionTypeNode != null)
     {
         if (actionTypeNode.Attributes["href"] != null || actionTypeNode.Attributes["id"] != null) 
         {
             if (actionTypeNode.Attributes["id"] != null) 
             {
                 actionTypeIDRef_ = actionTypeNode.Attributes["id"].Value;
                 XsdTypeToken ob = new XsdTypeToken(actionTypeNode);
                 IDManager.SetID(actionTypeIDRef_, ob);
             }
             else if (actionTypeNode.Attributes["href"] != null)
             {
                 actionTypeIDRef_ = actionTypeNode.Attributes["href"].Value;
             }
             else
             {
                 actionType_ = new XsdTypeToken(actionTypeNode);
             }
         }
         else
         {
             actionType_ = new XsdTypeToken(actionTypeNode);
         }
     }
     
 
 }
Example #11
0
        public void from(XmlNode node, XmlNamespaceManager xnm, string prefix, string subfix)
        {
            Type type = this.GetType();
            FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

            foreach (FieldInfo field in fields)
            {
                string query = prefix +ObjectUtil.GetSimpleName(field) + subfix;
                try
                {
                    string value = null;
                    XmlNode tempNode;
                    if (xnm != null)
                    {
                        tempNode = node.SelectSingleNode(query, xnm);
                    }
                    else
                    {
                        tempNode = node.SelectSingleNode(query);
                    }
                    if (tempNode == null) {
                        field.SetValue(this,XML_NULL);
                        continue;
                    }
                    value = tempNode.InnerText;
                    field.SetValue(this, value);
                }
                catch (Exception ex) { }
            }
        }
	// Constructor.
	internal XmlElement(XmlNode parent, NameCache.NameInfo name)
			: base(parent)
			{
				this.name = name;
				this.attributes = null;
				this.isEmpty = true;
			}
		Field _lField;			// resolved label name
		internal DataSetReference(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			_DataSetName=null;
			_ValueField=null;
			_LabelField=null;

			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "DataSetName":
						_DataSetName = xNodeLoop.InnerText;
						break;
					case "ValueField":
						_ValueField = xNodeLoop.InnerText;
						break;
					case "LabelField":
						_LabelField = xNodeLoop.InnerText;
						break;
					default:
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown DataSetReference element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
			}
			if (_DataSetName == null)
				OwnerReport.rl.LogError(8, "DataSetReference DataSetName is required but not specified.");
			if (_ValueField == null)
				OwnerReport.rl.LogError(8, "DataSetReference ValueField is required but not specified for" + _DataSetName==null? "<unknown name>": _DataSetName);
		}
Example #14
0
        List<TableGroup> _Items;			// list of TableGroup entries

		internal TableGroups(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			TableGroup tg;
            _Items = new List<TableGroup>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "TableGroup":
						tg = new TableGroup(r, this, xNodeLoop);
						break;
					default:	
						tg=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown TableGroups element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (tg != null)
					_Items.Add(tg);
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "For TableGroups at least one TableGroup is required.");
			else
                _Items.TrimExcess();
		}
 public Excel_cds(XmlNode xmlNode)
 : base(xmlNode)
 {
     XmlNode excel_swapLegNode = xmlNode.SelectSingleNode("excel_swapLeg");
     
     if (excel_swapLegNode != null)
     {
         if (excel_swapLegNode.Attributes["href"] != null || excel_swapLegNode.Attributes["id"] != null) 
         {
             if (excel_swapLegNode.Attributes["id"] != null) 
             {
                 excel_swapLegIDRef_ = excel_swapLegNode.Attributes["id"].Value;
                 Excel_swapLeg ob = new Excel_swapLeg(excel_swapLegNode);
                 IDManager.SetID(excel_swapLegIDRef_, ob);
             }
             else if (excel_swapLegNode.Attributes["href"] != null)
             {
                 excel_swapLegIDRef_ = excel_swapLegNode.Attributes["href"].Value;
             }
             else
             {
                 excel_swapLeg_ = new Excel_swapLeg(excel_swapLegNode);
             }
         }
         else
         {
             excel_swapLeg_ = new Excel_swapLeg(excel_swapLegNode);
         }
     }
     
 
     XmlNode excel_creditEventSwapLegNode = xmlNode.SelectSingleNode("excel_creditEventSwapLeg");
     
     if (excel_creditEventSwapLegNode != null)
     {
         if (excel_creditEventSwapLegNode.Attributes["href"] != null || excel_creditEventSwapLegNode.Attributes["id"] != null) 
         {
             if (excel_creditEventSwapLegNode.Attributes["id"] != null) 
             {
                 excel_creditEventSwapLegIDRef_ = excel_creditEventSwapLegNode.Attributes["id"].Value;
                 Excel_creditEventSwapLeg ob = new Excel_creditEventSwapLeg(excel_creditEventSwapLegNode);
                 IDManager.SetID(excel_creditEventSwapLegIDRef_, ob);
             }
             else if (excel_creditEventSwapLegNode.Attributes["href"] != null)
             {
                 excel_creditEventSwapLegIDRef_ = excel_creditEventSwapLegNode.Attributes["href"].Value;
             }
             else
             {
                 excel_creditEventSwapLeg_ = new Excel_creditEventSwapLeg(excel_creditEventSwapLegNode);
             }
         }
         else
         {
             excel_creditEventSwapLeg_ = new Excel_creditEventSwapLeg(excel_creditEventSwapLegNode);
         }
     }
     
 
 }
Example #16
0
		bool _FixedHeader=false;	// Header of this column should be display even when scrolled
	
		internal TableColumn(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			_Width=null;
			_Visibility=null;

			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "Width":
						_Width = new RSize(r, xNodeLoop);
						break;
					case "Visibility":
						_Visibility = new Visibility(r, this, xNodeLoop);
						break;
					case "FixedHeader":
						_FixedHeader = XmlUtil.Boolean(xNodeLoop.InnerText, OwnerReport.rl);
						break;
					default:
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown TableColumn element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
			}
			if (_Width == null)
				OwnerReport.rl.LogError(8, "TableColumn requires the Width element.");
		}
 public RefVariable_returnValue(XmlNode xmlNode)
 : base(xmlNode)
 {
     XmlNode variableInfoNode = xmlNode.SelectSingleNode("variableInfo");
     
     if (variableInfoNode != null)
     {
         if (variableInfoNode.Attributes["href"] != null || variableInfoNode.Attributes["id"] != null) 
         {
             if (variableInfoNode.Attributes["id"] != null) 
             {
                 variableInfoIDRef_ = variableInfoNode.Attributes["id"].Value;
                 VariableInfo ob = new VariableInfo(variableInfoNode);
                 IDManager.SetID(variableInfoIDRef_, ob);
             }
             else if (variableInfoNode.Attributes["href"] != null)
             {
                 variableInfoIDRef_ = variableInfoNode.Attributes["href"].Value;
             }
             else
             {
                 variableInfo_ = new VariableInfo(variableInfoNode);
             }
         }
         else
         {
             variableInfo_ = new VariableInfo(variableInfoNode);
         }
     }
     
 
 }
Example #18
0
 public DocumentXPathNavigator(DocumentXPathNavigator other)
 {
     _document = other._document;
     _source = other._source;
     _attributeIndex = other._attributeIndex;
     _namespaceParent = other._namespaceParent;
 }
        /// <summary>
        /// Reads a URI.
        /// </summary>
        /// <param name="node">The node containing the URI.</param>
        /// <param name="table">The serialiser table.</param>
        /// <returns>A new instance of a <see cref="Uri"/> if the node is valid; null otherwise.</returns>
        public override object Read(XmlNode node, NetReflectorTypeTable table)
        {
            if (node == null)
            {
                // NetReflector should do this check, but doesn't
                if (this.Attribute.Required)
                {
                    throw new NetReflectorItemRequiredException(Attribute.Name + " is required");
                }
                else
                {
                    return null;
                }
            }

            Uri ret;
            if (node is XmlAttribute)
            {
                ret = new Uri(node.Value);
            }
            else
            {
                ret = new Uri(node.InnerText);
            }

            return ret;
        }
 public Variable(XmlNode xmlNode)
 {
     XmlNodeList symbolNameNodeList = xmlNode.SelectNodes("symbolName");
     if (symbolNameNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in symbolNameNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 symbolNameIDRef = item.Attributes["id"].Name;
                 XsdTypeToken ob = XsdTypeToken();
                 IDManager.SetID(symbolNameIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 symbolNameIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 symbolName = new XsdTypeToken(item);
             }
         }
     }
     
 
 }
	/// <summary>
	/// Constructor
	/// </summary>
	/// <param name="context"/>
	/// <param name="location"/>
	public InflAffixTemplateEventArgs(Control context, XmlNode node, Point location, int tag)
	{
		m_location = location;
		m_node = node;
		m_contextControl = context;
		m_tag = tag;
	}
Example #22
0
 /// <summary>
 /// constructor
 /// </summary>
 public TaskListCheck(XmlNode Node, Ict.Common.Controls.TVisualStylesEnum Style)
 {
     //
     // The InitializeComponent() call is required for Windows Forms designer support.
     //
     InitializeComponent(Node, Style);
 }
	/// <summary>
	/// Deserializes the specified section.
	/// </summary>
	/// <param name="section">The section.</param>
	public void Deserialize(XmlNode section)
	{
		var customFactoryNode = section.SelectSingleNode("customControllerFactory");
		
		if (customFactoryNode != null)
		{
			var typeAtt = customFactoryNode.Attributes["type"];
			
			if (typeAtt == null || typeAtt.Value == String.Empty)
			{
				var message = "If the node customControllerFactory is " + 
					"present, you must specify the 'type' attribute";
				throw new ConfigurationErrorsException(message);
			}
			
			var typeName = typeAtt.Value;
			
			customControllerFactory = TypeLoadUtil.GetType(typeName);
		}
		
		var nodeList = section.SelectNodes("controllers/assembly");
		
		foreach(XmlNode node in nodeList)
		{
			if (node.HasChildNodes)
			{
				assemblies.Add(node.ChildNodes[0].Value);
			}
		}
	}
        protected override void ParseItem(XmlNode item)
        {
            Status status = new Status(item);
            this.statuses.Add(status);

            base.ParseItem(item);
        }
Example #25
0
        public new void fromXml(XmlNode node)
        {
            base.fromXml(node);

            XmlNode variableNameNode = ((XmlElement)node).GetElementsByTagName("Variable_Name").Item(0);
            this.variableName = variableNameNode.InnerText;
        }
        private static SortedDictionary<string, int> GetArtists(XmlNode rootNode)
        {
            var artists = new SortedDictionary<string, int>();

            if (rootNode == null)
            {
                throw new ArgumentNullException("rootNode" + "is empty");
            }

            foreach (var artistName in from XmlNode node in rootNode.ChildNodes
                                       select node["artist"] into xmlElement
                                       where xmlElement != null
                                       select xmlElement.InnerText)
            {
                if (artists.ContainsKey(artistName))
                {
                    artists[artistName]++;
                }
                else
                {
                    artists.Add(artistName, 1);
                }
            }

            return artists;
        }
 public CreditDefaultSwapOption(XmlNode xmlNode)
 : base(xmlNode)
 {
     XmlNode strikeNode = xmlNode.SelectSingleNode("strike");
     
     if (strikeNode != null)
     {
         if (strikeNode.Attributes["href"] != null || strikeNode.Attributes["id"] != null) 
         {
             if (strikeNode.Attributes["id"] != null) 
             {
                 strikeIDRef_ = strikeNode.Attributes["id"].Value;
                 CreditOptionStrike ob = new CreditOptionStrike(strikeNode);
                 IDManager.SetID(strikeIDRef_, ob);
             }
             else if (strikeNode.Attributes["href"] != null)
             {
                 strikeIDRef_ = strikeNode.Attributes["href"].Value;
             }
             else
             {
                 strike_ = new CreditOptionStrike(strikeNode);
             }
         }
         else
         {
             strike_ = new CreditOptionStrike(strikeNode);
         }
     }
     
 
     XmlNode creditDefaultSwapNode = xmlNode.SelectSingleNode("creditDefaultSwap");
     
     if (creditDefaultSwapNode != null)
     {
         if (creditDefaultSwapNode.Attributes["href"] != null || creditDefaultSwapNode.Attributes["id"] != null) 
         {
             if (creditDefaultSwapNode.Attributes["id"] != null) 
             {
                 creditDefaultSwapIDRef_ = creditDefaultSwapNode.Attributes["id"].Value;
                 CreditDefaultSwap ob = new CreditDefaultSwap(creditDefaultSwapNode);
                 IDManager.SetID(creditDefaultSwapIDRef_, ob);
             }
             else if (creditDefaultSwapNode.Attributes["href"] != null)
             {
                 creditDefaultSwapIDRef_ = creditDefaultSwapNode.Attributes["href"].Value;
             }
             else
             {
                 creditDefaultSwap_ = new CreditDefaultSwap(creditDefaultSwapNode);
             }
         }
         else
         {
             creditDefaultSwap_ = new CreditDefaultSwap(creditDefaultSwapNode);
         }
     }
     
 
 }
Example #28
0
        /// <summary>
        /// 通过xml找到其中的版本信息
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        public static string FindXmlNode(XmlNode xmlNode)
        {
            string version = string.Empty;
            if (xmlNode.Name == "ArchitectureToolsVersion")
            {
                version = xmlNode.Value;
            }
            else
            {
                if (xmlNode.HasChildNodes)
                {
                    foreach (XmlNode xn in xmlNode.ChildNodes)
                    {
                        if (xn.Name == "ArchitectureToolsVersion")
                        {
                            version = xn.InnerText;
                            break;
                        }
                        else
                        {
                            version = FindXmlNode(xn);
                            if (!string.IsNullOrEmpty(version))
                                break;
                        }
                    }
                }
            }

            return version;
        }
Example #29
0
 public void ParseNode(XmlNode n)
 {
     _BaseCharge = XmlHelper.ParseDecimal(n, "BaseCharge");
     if (n != null)
     {
         XmlNode sn = n.SelectSingleNode("Surcharges");
         if (sn != null)
         {
             foreach (XmlNode snn in sn.ChildNodes)
             {
                 string description = snn.Name;
                 string tempAmount = snn.InnerText;
                 decimal amount = 0m;
                 decimal.TryParse(tempAmount, System.Globalization.NumberStyles.Float, 
                     System.Globalization.CultureInfo.InvariantCulture,out amount);
                 Surcharges.Add(new Surcharge(description, amount));
             }
         }
     }
     _TotalSurcharge = XmlHelper.ParseDecimal(n, "TotalSurcharge");
     _NetCharge = XmlHelper.ParseDecimal(n, "NetCharge");
     _ShipmentNetCharge = XmlHelper.ParseDecimal(n, "ShipmentNetCharge");
     _TotalRebate = XmlHelper.ParseDecimal(n, "TotalRebate");
     _TotalDiscount = XmlHelper.ParseDecimal(n, "TotalDiscount");
 }
        public CustomXmlNodeList(XmlNode[] elements)
        {
            if (elements == null)
                throw new ArgumentException();

            this._elements = elements;
        }