示例#1
0
        internal DataItem GetDataItemFromXml(XmlNode node)
        {
            DataItem item = new DataItem();

            item.Name = node.Name;

            if (node.Value.ContainsText())
            {
                item.Value = node.InnerText;
            }

            foreach (XmlAttribute attr in node.Attributes)
            {
                item.AddAttribute(attr.Name, attr.Value);
            }

            if (node.HasChildNodes)
            {
                foreach (XmlNode child in node.ChildNodes)
                {
                    if (child.HasChildNodes)
                    {
                        item.Items.Add(GetDataItemFromXml(child));
                    }
                    else
                    {
                        item.Value = child.InnerText;
                    }
                }
            }

            return(item);
        }
示例#2
0
        internal ApiMethodResults GetMethodResultsFromNode(XmlNode node)
        {
            ApiMethodResults results = new ApiMethodResults();
            DataItem         result;

            if (node.InnerXml.ContainsText())
            {
                results.ValueRaw = node.InnerXml;
            }

            foreach (XmlNode child in node.ChildNodes)
            {
                if (child.NodeType == XmlNodeType.Element)
                {
                    result       = new DataItem();
                    result.Name  = child.Name;
                    result.Value = child.InnerText;                       //Note: changed to inner text b/c we want the unencoded value

                    foreach (XmlAttribute attr in child.Attributes)
                    {
                        result.AddAttribute(attr.Name, attr.Value);
                    }

                    foreach (XmlNode grandchild in child.ChildNodes)
                    {
                        if (grandchild.NodeType == XmlNodeType.Element)
                        {
                            if (grandchild.HasChildNodes)
                            {
                                result.Items.Add(GetDataItemFromXml(grandchild));
                            }
                            else
                            {
                                result.Items.Add(new DataItem()
                                {
                                    Name = grandchild.Name, Value = grandchild.InnerText
                                });
                            }
                        }
                    }

                    results.Items.Add(result);
                }
            }

            return(results);
        }
        public DataItem Serialize()
        {
            DataItem customField;
            DataItem valuesItem;

            customField      = new DataItem();
            customField.Name = "CustomFieldResponse";
            customField.AddAttribute("FieldCode", this.FieldCode);

            valuesItem = new DataItem("Values", string.Empty);

            foreach (string value in this.Values)
            {
                valuesItem.AddChild("Value", value);
            }

            customField.Items.Add(valuesItem);

            return(customField);
        }