public void NodeReaderReadAttributeValueWithAttributeXml()
        {
            string        xml        = "<root attr='val'><child /></root>";
            XmlNodeReader nodeReader = NodeReaderTestHelper.CreateNodeReader(xml);

            Assert.True(nodeReader.Read());
            Assert.Equal("root", nodeReader.Name);
            Assert.True(nodeReader.MoveToAttribute("attr"));
            Assert.True(nodeReader.ReadAttributeValue());
            Assert.Equal(ReadState.Interactive, nodeReader.ReadState);
            Assert.Equal(XmlNodeType.Text, nodeReader.NodeType);
            Assert.Equal(2, nodeReader.Depth);
            Assert.True(nodeReader.HasValue);
            Assert.Equal("val", nodeReader.Value);
            Assert.Equal(1, nodeReader.AttributeCount);
        }
        public static IDictionary <string, string> ParseSchemaHeader(this XmlNodeReader reader)
        {
            IDictionary <string, string> nsTable = new Dictionary <string, string>();

            for (int i = 0; i < reader.AttributeCount; i++)
            {
                reader.MoveToAttribute(i);

                if (reader.Name.Contains("xmlns:"))
                {
                    nsTable.Add(reader.Name.Substring(6), reader.ReadContentAsString());
                }
            }

            return(nsTable);
        }
Example #3
0
        public void parse()
        {
            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml(a);
            //x.LoadXml(@"C:\app\vs2019\VC#\mywork\XMLParser\XMLParser\bin\Debug\demo.xml");
            Console.WriteLine(formatXml(a));
            //Console.WriteLine(x.InnerXml);
            XmlNodeReader xmlNode = new XmlNodeReader(xdoc.GetElementsByTagName("library")[0]);

            Console.WriteLine("Node library Value: " + xmlNode.Value);                                                      //打印获取值
            Console.WriteLine("XmlDocument ChildNodes.Count: " + xdoc.ChildNodes.Count);                                    //打印子节点数量
            Console.WriteLine("XmlDocument ChildNodes[0].Name: " + xdoc.ChildNodes[0].Name);                                //打印节点名称
            Console.WriteLine("Node library MoveToContent(): " + xmlNode.MoveToContent());                                  //如果有下一个节点,直接指向下一个节点
            Console.WriteLine("Node library AttributeCount: " + xmlNode.AttributeCount);                                    //打印属性数量
            Console.WriteLine("Node library MoveToAttribute(\"id\"): " + xmlNode.MoveToAttribute("id"));                    //获取该属性节点的值
            Console.WriteLine("Node library Value: " + xmlNode.Value);                                                      //打印获取值
            Console.WriteLine("Node library name: " + xdoc.GetElementsByTagName("library")[0].Name);                        //打印节点名称
            Console.WriteLine("Node library attr id: " + xdoc.GetElementsByTagName("library")[0].Attributes["id"].Value);   //打印节点属性值
            Console.WriteLine("Node name innertext: " + xdoc.GetElementsByTagName("name")[0].InnerText);                    //打印节点值
            Console.WriteLine("Node name attr count: " + xdoc.GetElementsByTagName("name")[0].Attributes.Count);            //打印属性数量
            Console.WriteLine("Node name attr txt value: " + xdoc.GetElementsByTagName("name")[0].Attributes["txt"].Value); //打印属性值
            Console.WriteLine("XmlDocument Name: " + xdoc.DocumentElement.Name);
            Console.WriteLine("XmlDocument FirstChild Name: " + xdoc.DocumentElement.FirstChild.Name);

            XmlNodeList nodeList = xdoc.DocumentElement.ChildNodes;

            foreach (XmlElement xe in nodeList)
            {
                Console.WriteLine(xdoc.DocumentElement.Name + " Child Name:" + xe.Name);
            }
            nodeList = xdoc.DocumentElement.FirstChild.ChildNodes;
            foreach (XmlElement xe in nodeList)
            {
                Console.WriteLine(xe.InnerText);
                if (xe.HasAttributes)
                {
                    Console.WriteLine(xe.Attributes.Count);
                    for (int i = 0; i < xe.Attributes.Count; i++)
                    {
                        Console.WriteLine(xe.Attributes[i].Name);
                    }
                    Console.WriteLine(xe.Attributes["id"].Value);
                    Console.WriteLine(xe.Attributes["txt"].Value);
                }
            }
        }
        public void NodeReaderReadContentAsBase64WithSimpleXml()
        {
            byte[]        byteData   = "hello world" u8.ToArray();
            string        xml        = $"<root attr='{Convert.ToBase64String(byteData)}'><child /></root>"; //hello world encoded
            XmlNodeReader nodeReader = NodeReaderTestHelper.CreateNodeReader(xml);

            Assert.True(nodeReader.Read());
            Assert.Equal("root", nodeReader.Name);
            Assert.True(nodeReader.MoveToAttribute("attr"));
            Assert.True(nodeReader.CanReadBinaryContent);
            var resultArr = new byte[byteData.Length];

            Assert.Equal(byteData.Length, nodeReader.ReadContentAsBase64(resultArr, 0, byteData.Length));
            Assert.Equal(byteData, resultArr);
            Assert.Equal("hello world", Encoding.ASCII.GetString(resultArr));
            Assert.Equal(0, nodeReader.ReadContentAsBase64(new byte[33], 10, 10));
        }
Example #5
0
        public void NodeReaderReadContentAsBinHexWithSimpleXml()
        {
            byte[]        byteData   = Encoding.ASCII.GetBytes("hello world");
            string        xml        = $"<root attr='{BitConverter.ToString(byteData).Replace("-", "")}'><child /></root>";
            XmlNodeReader nodeReader = NodeReaderTestHelper.CreateNodeReader(xml);

            Assert.True(nodeReader.Read());
            Assert.Equal("root", nodeReader.Name);
            Assert.True(nodeReader.MoveToAttribute("attr"));
            Assert.True(nodeReader.CanReadBinaryContent);
            var resultArr = new byte[byteData.Length];

            Assert.Equal(byteData.Length, nodeReader.ReadContentAsBinHex(resultArr, 0, byteData.Length));
            Assert.Equal(byteData, resultArr);
            Assert.Equal("hello world", Encoding.ASCII.GetString(resultArr));
            Assert.Equal(0, nodeReader.ReadContentAsBinHex(new byte[33], 10, 10));
        }
Example #6
0
    public static void Main()
    {
        XmlNodeReader reader = null;

        try
        {
            //Create and load an XML document.
            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<!DOCTYPE book [<!ENTITY h 'harcover'>]>" +
                        "<book genre='novel' misc='sale-item &h; 1987'>" +
                        "</book>");

            //Create the reader.
            reader = new XmlNodeReader(doc);

            //Read the misc attribute. The attribute is parsed into multiple
            //text and entity reference nodes.
            reader.MoveToContent();
            reader.MoveToAttribute("misc");
            while (reader.ReadAttributeValue())
            {
                if (reader.NodeType == XmlNodeType.EntityReference)
                {
                    //To expand the entity, call ResolveEntity.
                    Console.WriteLine("{0} {1}", reader.NodeType, reader.Name);
                }
                else
                {
                    Console.WriteLine("{0} {1}", reader.NodeType, reader.Value);
                }
            }
        }
        finally
        {
            if (reader != null)
            {
                reader.Close();
            }
        }
    }
        List <string> ThesaurusParse(string xml)
        {
            List <string> synonyms = new List <string>();
            XmlDocument   doc      = new XmlDocument();

            doc.LoadXml(xml);
            XmlReader reader = new XmlNodeReader(doc);

            while (reader.ReadToFollowing("w") && synonyms.Count < synonymNumber)
            {
                reader.MoveToAttribute("r");
                string type = reader.Value;
                reader.MoveToContent();
                string result = reader.ReadInnerXml();
                if (type == "syn")
                {
                    synonyms.Add(result);
                }
            }

            return(synonyms);
        }
        public void NodeReaderMoveToAttributeWithAttributeXml()
        {
            string        xml        = "<root catr='tal' xmlns:attr='cal' fatr='gal' xmlns:attr2='val'></root>";
            XmlNodeReader nodeReader = NodeReaderTestHelper.CreateNodeReader(xml);

            Assert.True(nodeReader.Read());
            Assert.True(nodeReader.MoveToAttribute("catr"));
            Assert.True(nodeReader.MoveToAttribute("attr", "http://www.w3.org/2000/xmlns/"));
            nodeReader.MoveToAttribute(0);

            nodeReader.ReadContentAsBase64(new byte[33], 10, 10);
            Assert.True(nodeReader.MoveToAttribute("fatr"));
            nodeReader.ReadContentAsBase64(new byte[33], 10, 10);
            Assert.True(nodeReader.MoveToAttribute("attr2", "http://www.w3.org/2000/xmlns/"));
            nodeReader.ReadContentAsBase64(new byte[33], 10, 10);
            nodeReader.MoveToAttribute(1);
        }
        /// <summary>
        /// Parses an IM log file and sends the information to GDS
        /// </summary>
        /// <param name="logFile">The IM conversations log file</param>
        /// <param name="lastIndexed">messages older than this will not be sent to GDS</param>
        private void ParseAndSendMessages(string logFile, DateTime lastIndexed)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(logFile);
            XmlNodeReader reader = new XmlNodeReader(doc);

            // reset user and buddy name
            userName  = null;
            buddyName = null;

            // Moves the reader to the root element.
            reader.MoveToContent();

            // move to the first message
            reader.Read();

            while (reader.LocalName == "Message")
            {
                // check the date of the message - if older skip
                reader.MoveToAttribute("DateTime");
                DateTime messageDateTime = DateTime.Parse(reader.Value);
                reader.MoveToElement();

                // if older than the last indexing time, skip the message
                if (messageDateTime.CompareTo(lastIndexed) <= 0)
                {
                    reader.Skip();
                    continue;
                }

                // get message data
                MSNMessageData messageData = ParseMessageData(reader.ReadOuterXml());

                // send this message to GDS for indexing
                SendMessageData(messageData);
            }
        }
Example #10
0
        public static List <string> GetInitUserReg(string xmlurl, string Jname)
        {
            List <string> list = new List <string>();
            XmlDocument   xdd  = new XmlDocument();

            xdd.Load(xmlurl);
            XmlReader dr = new XmlNodeReader(xdd);

            while (dr.Read())
            {
                if (dr.NodeType == XmlNodeType.Element)
                {
                    if (dr.Name == Jname)
                    {
                        if (dr.MoveToAttribute("name"))
                        {
                            list.Add(dr.Value);
                        }
                    }
                }
            }

            return(list);
        }
Example #11
0
    public static void Main()
    {
        XmlNodeReader reader = null;

        try
        {
            //Create and load the XML document.
            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<book genre='novel' ISBN='1-861003-78' publicationdate='1987'> " +
                        "</book>");

            //Load the XmlNodeReader
            reader = new XmlNodeReader(doc);

            //Read the attributes on the root element.
            reader.MoveToContent();
            if (reader.HasAttributes)
            {
                for (int i = 0; i < reader.AttributeCount; i++)
                {
                    reader.MoveToAttribute(i);
                    Console.WriteLine("{0} = {1}", reader.Name, reader.Value);
                }
                //Return the reader to the book element.
                reader.MoveToElement();
            }
        }

        finally
        {
            if (reader != null)
            {
                reader.Close();
            }
        }
    }
Example #12
0
        private static void read_home(XmlNodeReader NodeReader, Item_Aggregation HierarchyObject)
        {
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:BODY":
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                        {
                            string bodyLanguage = NodeReader.GetAttribute("lang");
                            NodeReader.Read();
                            HierarchyObject.Add_Home_Page_File(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage));
                        }
                        else
                        {
                            NodeReader.Read();
                            HierarchyObject.Add_Home_Page_File(NodeReader.Value, Web_Language_Enum.DEFAULT);
                        }

                        break;
                    }
                }

                if ((NodeReader.NodeType == XmlNodeType.EndElement) && (NodeReader.Name.Trim().ToUpper() == "HI:HOME"))
                {
                    return;
                }
            }
        }
        private static void read_browse(bool browse, XmlNodeReader nodeReader, Item_Aggregation hierarchyObject)
        {
            // Create a new browse/info object
            Item_Aggregation_Browse_Info newBrowse = new Item_Aggregation_Browse_Info
            {
                Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_Home,
                Source      = Item_Aggregation_Browse_Info.Source_Type.Static_HTML,
                Data_Type   = Item_Aggregation_Browse_Info.Result_Data_Type.Text
            };

            bool isDefault = false;

            string code = String.Empty;

            // Determine which XML node name to look for and set browse v. info
            string lastName = "HI:BROWSE";

            if (!browse)
            {
                lastName = "HI:INFO";
                newBrowse.Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Info;
            }

            // Check for the attributes
            if (nodeReader.HasAttributes)
            {
                if (nodeReader.MoveToAttribute("location"))
                {
                    if (nodeReader.Value == "BROWSEBY")
                    {
                        newBrowse.Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_By;
                    }
                }
                if (nodeReader.MoveToAttribute("default"))
                {
                    if (nodeReader.Value == "DEFAULT")
                    {
                        isDefault = true;
                    }
                }
            }

            // Step through the XML and build this browse/info object
            while (nodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (nodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = nodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:METADATA":
                        nodeReader.Read();
                        newBrowse.Code      = nodeReader.Value.ToLower();
                        newBrowse.Source    = Item_Aggregation_Browse_Info.Source_Type.Database;
                        newBrowse.Data_Type = Item_Aggregation_Browse_Info.Result_Data_Type.Table;
                        break;

                    case "HI:CODE":
                        nodeReader.Read();
                        newBrowse.Code = nodeReader.Value.ToLower();
                        break;

                    case "HI:TITLE":
                        // Look for a language attached to this title
                        string titleLanguage = String.Empty;
                        if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang")))
                        {
                            titleLanguage = nodeReader.GetAttribute("lang");
                        }

                        // read and save the title
                        nodeReader.Read();
                        newBrowse.Add_Label(nodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(titleLanguage));
                        break;

                    case "HI:BODY":
                        // Look for a language attached to this title
                        string bodyLanguage = String.Empty;
                        if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang")))
                        {
                            bodyLanguage = nodeReader.GetAttribute("lang");
                        }

                        // read and save the title
                        nodeReader.Read();
                        string bodySource = nodeReader.Value;
                        newBrowse.Add_Static_HTML_Source(bodySource, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage));
                        break;
                    }
                }

                if (nodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (nodeReader.Name.Trim().ToUpper() == lastName)
                    {
                        hierarchyObject.Add_Browse_Info(newBrowse);

                        // If this set the default browse by save that information
                        if ((newBrowse.Browse_Type == Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_By) && (isDefault))
                        {
                            hierarchyObject.Default_BrowseBy = newBrowse.Code;
                        }

                        return;
                    }
                }
            }
        }
        private void process_bib_desc(XmlNodeReader nodeReader, SobekCM_Item thisPackage)
        {
            // Set some counters for the creator role/date and contributor role/date
            int creatorRole = 0;
            int creatorDate = 0;

            //int contribRole = 0;
            //int contribDate = 0;

            // Read all the nodes
            while (nodeReader.Read())
            {
                // If this is the end tag for bibDesc, return
                if ((nodeReader.NodeType == XmlNodeType.EndElement) && (nodeReader.Name.Trim().ToUpper() == "BIBDESC"))
                {
                    return;
                }

                // If this is the beginning tag for an element, assign the next values accordingly
                if (nodeReader.NodeType == XmlNodeType.Element)
                {
                    // Switch based on the element name
                    switch (nodeReader.Name.Trim().ToUpper())
                    {
                    case "DC.TITLE":
                        thisPackage.Bib_Info.Main_Title.Title = read_text_node(nodeReader);
                        break;

                    case "DC.RIGHTS":
                        thisPackage.Bib_Info.Access_Condition.Text = read_text_node(nodeReader);
                        break;

                    case "DC.IDENTIFIER":
                        thisPackage.Bib_Info.Add_Identifier(read_text_node(nodeReader));
                        break;

                    case "DC.DATE":
                        thisPackage.Bib_Info.Origin_Info.Date_Issued = read_text_node(nodeReader);
                        break;

                    case "DC.CREATOR":
                        thisPackage.Bib_Info.Add_Named_Entity(read_text_node(nodeReader), "creator");
                        break;

                    case "PALMM.CREATORROLE":
                        if (thisPackage.Bib_Info.Names_Count > creatorRole)
                        {
                            if (thisPackage.Bib_Info.Names[creatorRole].Roles.Count == 0)
                            {
                                thisPackage.Bib_Info.Names[creatorRole].Roles.Add(new Name_Info_Role(read_text_node(nodeReader), Name_Info_Role_Type_Enum.text));
                            }
                            else
                            {
                                thisPackage.Bib_Info.Names[creatorRole].Roles[0].Role = read_text_node(nodeReader);
                            }
                            creatorRole++;
                        }
                        break;

                    case "PALMM.CREATORDATES":
                        if (thisPackage.Bib_Info.Names_Count > creatorDate)
                        {
                            thisPackage.Bib_Info.Names[creatorDate++].Dates = read_text_node(nodeReader);
                        }
                        break;

                    case "DC.CONTRIBUTOR":
                        thisPackage.Bib_Info.Add_Named_Entity(new Name_Info(read_text_node(nodeReader), "contributor"));
                        break;

                    case "DC.DESCRIPTION":
                        thisPackage.Bib_Info.Add_Note(new Note_Info(read_text_node(nodeReader)));
                        break;

                    case "DC.SUBJECT":
                        if (nodeReader.HasAttributes)
                        {
                            nodeReader.MoveToAttribute(0);
                            string scheme = nodeReader.Value.Trim();
                            thisPackage.Bib_Info.Add_Subject(new Subject_Info_Standard(read_text_node(nodeReader), scheme));
                        }
                        else
                        {
                            thisPackage.Bib_Info.Add_Subject(new Subject_Info_Standard(read_text_node(nodeReader), String.Empty));
                        }
                        break;

                    case "PALMM.SPATIALNAME":
                        if (nodeReader.HasAttributes)
                        {
                            nodeReader.MoveToAttribute(0);
                            string scheme = nodeReader.Value.Trim();
                            Subject_Info_HierarchicalGeographic thisSpatial = new Subject_Info_HierarchicalGeographic();
                            thisSpatial.Authority = scheme;
                            thisSpatial.Area      = read_text_node(nodeReader);
                            thisPackage.Bib_Info.Add_Subject(thisSpatial);
                        }
                        else
                        {
                            Subject_Info_HierarchicalGeographic thisSpatial = new Subject_Info_HierarchicalGeographic();
                            thisSpatial.Area = read_text_node(nodeReader);
                            thisPackage.Bib_Info.Add_Subject(thisSpatial);
                        }
                        break;

                    case "DC.FORMAT.EXTENT":
                        thisPackage.Bib_Info.Original_Description.Extent = read_text_node(nodeReader);
                        break;

                    case "DC.TYPE":
                        if (thisPackage.Bib_Info.Original_Description.Extent.Length > 0)
                        {
                            thisPackage.Bib_Info.Original_Description.Extent = read_text_node(nodeReader) + " ( " + thisPackage.Bib_Info.Original_Description.Extent + " )";
                        }
                        else
                        {
                            thisPackage.Bib_Info.Original_Description.Extent = read_text_node(nodeReader);
                        }
                        break;

                    case "PALMM.LOCATION":
                        thisPackage.Bib_Info.Location.Holding_Name = read_text_node(nodeReader);
                        break;

                    case "PALMM.NOTES":
                        thisPackage.Bib_Info.Add_Note(read_text_node(nodeReader));
                        break;
                    }
                }
            }
        }
        private void process_packageDesc(XmlNodeReader nodeReader, SobekCM_Item thisPackage)
        {
            // Get the bib id first
            if (nodeReader.HasAttributes)
            {
                // Move to what should be the bib id attribute
                nodeReader.MoveToAttribute(0);
                if (nodeReader.Name == "id")
                {
                    thisPackage.BibID = nodeReader.Value.Trim();
                }
            }

            // Read in the rest of the data until the closing packageDesc tag
            while ((nodeReader.Read()) && (nodeReader.Name.Trim() != "packageDesc"))
            {
                // Is this the opening tag for contrib?
                if ((nodeReader.NodeType == XmlNodeType.Element) && (nodeReader.Name.Trim() == "contrib"))
                {
                    // Get the attribute
                    if (nodeReader.HasAttributes)
                    {
                        nodeReader.MoveToAttribute(0);
                        if (nodeReader.Name.Trim() == "creator")
                        {
                            // Get the value
                            string creatorValue = nodeReader.Value;

                            // If there is a comma, parse it
                            if (creatorValue.IndexOf(",") > 0)
                            {
                                string[] split = creatorValue.Split(",".ToCharArray());
                                thisPackage.METS_Header.Creator_Software   = split[0].Trim();
                                thisPackage.METS_Header.Creator_Individual = split[1].Trim();
                            }
                            else
                            {
                                thisPackage.METS_Header.Creator_Individual = creatorValue.Trim();
                            }
                        }
                    }

                    // Get the text of this... this is the institution that made the MXF
                    if ((nodeReader.Read()) && (nodeReader.NodeType == XmlNodeType.Text))
                    {
                        thisPackage.METS_Header.Creator_Organization = nodeReader.Value.Trim();
                    }
                }

                // Is this the opening tag for the timestamp?
                if ((nodeReader.NodeType == XmlNodeType.Element) && (nodeReader.Name.Trim() == "timestamp"))
                {
                    // Get the text of this... this is the timestamp
                    if ((nodeReader.Read()) && (nodeReader.NodeType == XmlNodeType.Text))
                    {
                        string mxf_dateString = nodeReader.Value.Trim();
                        string dateString     = mxf_dateString.Substring(0, 4) + "/" + mxf_dateString.Substring(4, 2) +
                                                "/" + mxf_dateString.Substring(6, 2) + " " + mxf_dateString.Substring(9, 2) + ":" + mxf_dateString.Substring(11, 2) + ":" + mxf_dateString.Substring(13, 2);
                        thisPackage.METS_Header.Create_Date = Convert.ToDateTime(dateString);
                    }
                }
            }
        }
Example #16
0
        private static void read_results_specs(XmlNodeReader NodeReader, Item_Aggregation HierarchyObject)
        {
            bool inViews = false;

            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                string nodeName;
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    nodeName = NodeReader.Name.Trim().ToUpper();

                    switch (nodeName)
                    {
                    case "HI:VIEWS":
                        inViews = true;
                        break;

                    case "HI:ADD":
                        if (inViews)
                        {
                            bool   isDefault = false;
                            string type      = String.Empty;
                            if (NodeReader.MoveToAttribute("default"))
                            {
                                isDefault = true;
                            }
                            if (NodeReader.MoveToAttribute("type"))
                            {
                                type = NodeReader.Value.ToUpper();
                            }
                            if (type.Length > 0)
                            {
                                Result_Display_Type_Enum displayType = Result_Display_Type_Enum.Default;
                                switch (type)
                                {
                                case "BRIEF":
                                    displayType = Result_Display_Type_Enum.Brief;
                                    break;

                                case "FULL":
                                    displayType = Result_Display_Type_Enum.Full_Citation;
                                    break;

                                case "THUMBNAIL":
                                    displayType = Result_Display_Type_Enum.Thumbnails;
                                    break;

                                case "TABLE":
                                    displayType = Result_Display_Type_Enum.Table;
                                    break;

                                case "MAP":
                                    displayType = Result_Display_Type_Enum.Map;
                                    break;
                                }
                                if (displayType != Result_Display_Type_Enum.Default)
                                {
                                    if (!HierarchyObject.Result_Views.Contains(displayType))
                                    {
                                        HierarchyObject.Result_Views.Add(displayType);
                                    }
                                    if (isDefault)
                                    {
                                        HierarchyObject.Default_Result_View = displayType;
                                    }
                                }
                            }
                        }
                        break;

                    case "HI:REMOVE":
                        if (inViews)
                        {
                            string type = String.Empty;
                            if (NodeReader.MoveToAttribute("type"))
                            {
                                type = NodeReader.Value.ToUpper();
                            }
                            if (type.Length > 0)
                            {
                                Result_Display_Type_Enum displayType = Result_Display_Type_Enum.Default;
                                switch (type)
                                {
                                case "BRIEF":
                                    displayType = Result_Display_Type_Enum.Brief;
                                    break;

                                case "FULL":
                                    displayType = Result_Display_Type_Enum.Full_Citation;
                                    break;

                                case "THUMBNAIL":
                                    displayType = Result_Display_Type_Enum.Thumbnails;
                                    break;

                                case "TABLE":
                                    displayType = Result_Display_Type_Enum.Table;
                                    break;

                                case "MAP":
                                    displayType = Result_Display_Type_Enum.Map;
                                    break;
                                }
                                if (displayType != Result_Display_Type_Enum.Default)
                                {
                                    if (HierarchyObject.Result_Views.Contains(displayType))
                                    {
                                        HierarchyObject.Result_Views.Remove(displayType);
                                    }
                                }
                            }
                        }
                        break;
                    }
                }

                // If this is not an end element, continue
                if (NodeReader.NodeType != XmlNodeType.EndElement)
                {
                    continue;
                }

                // Get the node name, trimmed and to upper
                nodeName = NodeReader.Name.Trim().ToUpper();

                switch (nodeName)
                {
                case "HI:VIEWS":
                    inViews = false;
                    break;

                case "HI:RESULTS":
                    return;
                }
            }
        }
        private static void read_banners(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject)
        {
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:SOURCE":
                        // Check for any attributes to this banner node
                        string lang    = String.Empty;
                        bool   special = false;
                        Item_Aggregation_Front_Banner_Type_Enum type = Item_Aggregation_Front_Banner_Type_Enum.Left;
                        ushort width  = 550;
                        ushort height = 230;

                        if (NodeReader.HasAttributes)
                        {
                            if (NodeReader.MoveToAttribute("lang"))
                            {
                                lang = NodeReader.Value.Trim().ToUpper();
                            }
                            if (NodeReader.MoveToAttribute("type"))
                            {
                                if ((NodeReader.Value.Trim().ToUpper() == "HIGHLIGHT") || (NodeReader.Value.Trim().ToUpper() == "FRONT"))
                                {
                                    special = true;
                                }
                            }
                            if (NodeReader.MoveToAttribute("side"))
                            {
                                switch (NodeReader.Value.Trim().ToUpper())
                                {
                                case "RIGHT":
                                    type = Item_Aggregation_Front_Banner_Type_Enum.Right;
                                    break;

                                case "LEFT":
                                    type = Item_Aggregation_Front_Banner_Type_Enum.Left;
                                    break;

                                case "FULL":
                                    type = Item_Aggregation_Front_Banner_Type_Enum.Full;
                                    break;
                                }
                            }
                            if (NodeReader.MoveToAttribute("width"))
                            {
                                ushort.TryParse(NodeReader.Value, out width);
                            }
                            if (NodeReader.MoveToAttribute("height"))
                            {
                                ushort.TryParse(NodeReader.Value, out height);
                            }
                        }

                        // Now read the banner information and add to the aggregation object
                        NodeReader.Read();
                        if (special)
                        {
                            Item_Aggregation_Front_Banner bannerObj = HierarchyObject.Add_Front_Banner_Image(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(lang));
                            bannerObj.Width  = width;
                            bannerObj.Height = height;
                            bannerObj.Type   = type;
                        }
                        else
                        {
                            HierarchyObject.Add_Banner_Image(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(lang));
                        }


                        break;
                    }
                }

                if ((NodeReader.NodeType == XmlNodeType.EndElement) && (NodeReader.Name.Trim().ToUpper() == "HI:BANNER"))
                {
                    return;
                }
            }
        }
        private static void read_highlights(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject)
        {
            Complete_Item_Aggregation_Highlights highlight = new Complete_Item_Aggregation_Highlights();


            // Determine if this is a rotating type of highlight or not
            if (NodeReader.HasAttributes)
            {
                if (NodeReader.MoveToAttribute("type"))
                {
                    if (NodeReader.Value == "ROTATING")
                    {
                        HierarchyObject.Rotating_Highlights = true;
                    }
                }

                if (HierarchyObject.Front_Banner_Dictionary != null)
                {
                    // The following three values are for reading legacy XML files.  These
                    // data fields have been moved to be attached to the actual banner
                    if (NodeReader.MoveToAttribute("bannerSide"))
                    {
                        if (NodeReader.Value.Trim().ToUpper() == "RIGHT")
                        {
                            foreach (KeyValuePair <Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary)
                            {
                                banners.Value.Type = Item_Aggregation_Front_Banner_Type_Enum.Right;
                            }
                        }
                        else
                        {
                            foreach (KeyValuePair <Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary)
                            {
                                banners.Value.Type = Item_Aggregation_Front_Banner_Type_Enum.Left;
                            }
                        }
                    }
                    if (NodeReader.MoveToAttribute("bannerHeight"))
                    {
                        foreach (KeyValuePair <Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary)
                        {
                            banners.Value.Height = Convert.ToUInt16(NodeReader.Value);
                        }
                    }
                    if (NodeReader.MoveToAttribute("bannerWidth"))
                    {
                        foreach (KeyValuePair <Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary)
                        {
                            banners.Value.Width = Convert.ToUInt16(NodeReader.Value);
                        }
                    }
                }
            }

            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    string languageText;
                    switch (nodeName)
                    {
                    case "HI:SOURCE":
                        NodeReader.Read();
                        highlight.Image = NodeReader.Value.ToLower();
                        break;

                    case "HI:LINK":
                        NodeReader.Read();
                        highlight.Link = NodeReader.Value.ToLower();
                        break;

                    case "HI:TOOLTIP":
                        languageText = String.Empty;
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                        {
                            languageText = NodeReader.Value.ToUpper();
                        }
                        NodeReader.Read();
                        highlight.Add_Tooltip(Web_Language_Enum_Converter.Code_To_Enum(languageText), NodeReader.Value);
                        break;

                    case "HI:TEXT":
                        languageText = String.Empty;
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                        {
                            languageText = NodeReader.Value.ToUpper();
                        }
                        NodeReader.Read();
                        highlight.Add_Text(Web_Language_Enum_Converter.Code_To_Enum(languageText), NodeReader.Value);
                        break;
                    }
                }

                if (NodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (NodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHT")
                    {
                        if (HierarchyObject.Highlights == null)
                        {
                            HierarchyObject.Highlights = new List <Complete_Item_Aggregation_Highlights>();
                        }
                        HierarchyObject.Highlights.Add(highlight);
                        highlight = new Complete_Item_Aggregation_Highlights();
                    }

                    if (NodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHTS")
                    {
                        // Done with all the highlights so return
                        return;
                    }
                }
            }
        }
        private static void read_browse(bool Browse, XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject)
        {
            // Create a new browse/info object
            Complete_Item_Aggregation_Child_Page newBrowse = new Complete_Item_Aggregation_Child_Page
            {
                Browse_Type      = Item_Aggregation_Child_Visibility_Enum.Main_Menu,
                Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Static_HTML
            };

            bool isDefault = false;

            // Determine which XML node name to look for and set browse v. info
            string lastName = "HI:BROWSE";

            if (!Browse)
            {
                lastName = "HI:INFO";
                newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None;
            }

            // Check for the attributes
            if (NodeReader.HasAttributes)
            {
                if (NodeReader.MoveToAttribute("location"))
                {
                    if (NodeReader.Value == "BROWSEBY")
                    {
                        newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By;
                    }
                }
                if (NodeReader.MoveToAttribute("default"))
                {
                    if (NodeReader.Value == "DEFAULT")
                    {
                        isDefault = true;
                    }
                }
                if (NodeReader.MoveToAttribute("visibility"))
                {
                    switch (NodeReader.Value)
                    {
                    case "NONE":
                        newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None;
                        break;

                    case "MAIN_MENU":
                        newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Main_Menu;
                        break;

                    case "BROWSEBY":
                        newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By;
                        break;
                    }
                }
                if (NodeReader.MoveToAttribute("parent"))
                {
                    newBrowse.Parent_Code = NodeReader.Value;
                }
            }

            // Step through the XML and build this browse/info object
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:METADATA":
                        NodeReader.Read();
                        newBrowse.Code             = NodeReader.Value.ToLower();
                        newBrowse.Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Database_Table;
                        break;

                    case "HI:CODE":
                        NodeReader.Read();
                        newBrowse.Code = NodeReader.Value.ToLower();
                        break;

                    case "HI:TITLE":
                        // Look for a language attached to this title
                        string titleLanguage = String.Empty;
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                        {
                            titleLanguage = NodeReader.GetAttribute("lang");
                        }

                        // read and save the title
                        NodeReader.Read();
                        newBrowse.Add_Label(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(titleLanguage));
                        break;

                    case "HI:BODY":
                        // Look for a language attached to this title
                        string bodyLanguage = String.Empty;
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                        {
                            bodyLanguage = NodeReader.GetAttribute("lang");
                        }

                        // read and save the title
                        NodeReader.Read();
                        string bodySource = NodeReader.Value;
                        newBrowse.Add_Static_HTML_Source(bodySource, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage));
                        break;
                    }
                }

                if (NodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (NodeReader.Name.Trim().ToUpper() == lastName)
                    {
                        // Don't add ALL or NEW here
                        if ((String.Compare(newBrowse.Code, "all", StringComparison.InvariantCultureIgnoreCase) != 0) && (String.Compare(newBrowse.Code, "new", StringComparison.InvariantCultureIgnoreCase) != 0))
                        {
                            HierarchyObject.Add_Child_Page(newBrowse);
                            //HierarchyObject.Add

                            // If this set the default browse by save that information
                            if ((newBrowse.Browse_Type == Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By) && (isDefault))
                            {
                                HierarchyObject.Default_BrowseBy = newBrowse.Code;
                            }
                        }

                        return;
                    }
                }
            }
        }
        private static void read_highlights(XmlNodeReader nodeReader, Item_Aggregation hierarchyObject)
        {
            Item_Aggregation_Highlights highlight = new Item_Aggregation_Highlights();


            // Determine if this is a rotating type of highlight or not
            if (nodeReader.HasAttributes)
            {
                if (nodeReader.MoveToAttribute("type"))
                {
                    if (nodeReader.Value == "ROTATING")
                    {
                        hierarchyObject.Rotating_Highlights = true;
                    }
                }
                if (nodeReader.MoveToAttribute("bannerSide"))
                {
                    if (nodeReader.Value.Trim().ToUpper() == "RIGHT")
                    {
                        hierarchyObject.Front_Banner_Left_Side = false;
                    }
                }
                if (nodeReader.MoveToAttribute("bannerHeight"))
                {
                    hierarchyObject.Front_Banner_Height = Convert.ToUInt16(nodeReader.Value);
                }
                if (nodeReader.MoveToAttribute("bannerWidth"))
                {
                    hierarchyObject.Front_Banner_Width = Convert.ToUInt16(nodeReader.Value);
                }
            }

            while (nodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (nodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = nodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    string languageText;
                    switch (nodeName)
                    {
                    case "HI:SOURCE":
                        nodeReader.Read();
                        highlight.Image = nodeReader.Value.ToLower();
                        break;

                    case "HI:LINK":
                        nodeReader.Read();
                        highlight.Link = nodeReader.Value.ToLower();
                        break;

                    case "HI:TOOLTIP":
                        languageText = String.Empty;
                        if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang")))
                        {
                            languageText = nodeReader.Value.ToUpper();
                        }
                        nodeReader.Read();
                        highlight.Add_Tooltip(Web_Language_Enum_Converter.Code_To_Enum(languageText), nodeReader.Value);
                        break;

                    case "HI:TEXT":
                        languageText = String.Empty;
                        if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang")))
                        {
                            languageText = nodeReader.Value.ToUpper();
                        }
                        nodeReader.Read();
                        highlight.Add_Text(Web_Language_Enum_Converter.Code_To_Enum(languageText), nodeReader.Value);
                        break;
                    }
                }

                if (nodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (nodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHT")
                    {
                        hierarchyObject.Highlights.Add(highlight);
                        highlight = new Item_Aggregation_Highlights();
                    }

                    if (nodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHTS")
                    {
                        // Done with all the highlights so return
                        return;
                    }
                }
            }
        }
        /// <summary>
        /// Captures MSN conversations
        /// </summary>
        /// <param name="xmlMessage">xml string containing an IM message data</param>
        /// <returns>an MSNMessageData struct containing the parsed data</returns>
        private MSNMessageData ParseMessageData(string xmlMessage)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xmlMessage);
            XmlNodeReader  reader      = new XmlNodeReader(doc);
            MSNMessageData messageData = new MSNMessageData();

            // Moves the reader to the root element.
            reader.MoveToContent();

            // get the date
            reader.MoveToAttribute("DateTime");
            messageData.date = DateTime.Parse(reader.Value);

            // get the session id
            reader.MoveToAttribute("SessionID");
            messageData.sessionId = Convert.ToInt32(reader.Value);

            // get the rest of the attributes
            while (reader.Read())
            {
                // advance to the inner node we're interested in
                if (reader.NodeType == XmlNodeType.Element)
                {
                    string parentNodeName = reader.LocalName;
                    reader.Read();

                    switch (parentNodeName)
                    {
                    case "From":
                        // get the from user
                        reader.MoveToAttribute("FriendlyName");
                        messageData.fromFriendlyName = reader.Value;
                        break;

                    case "To":
                        // get the to user
                        reader.MoveToAttribute("FriendlyName");
                        messageData.toFriendlyName = reader.Value;
                        break;

                    // get the actual IM message
                    case "Text":
                        messageData.message = reader.Value;
                        break;

                    default:
                        break;
                    }
                }
            }

            // set user and buddy names if not already set
            if (userName == null)
            {
                userName = messageData.fromFriendlyName;
            }

            if (buddyName == null)
            {
                buddyName = messageData.toFriendlyName;
            }

            return(messageData);
        }
        private static void read_settings(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject)
        {
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:WEBSKINS":
                        NodeReader.Read();
                        string webskins = NodeReader.Value;
                        if (!String.IsNullOrEmpty(webskins))
                        {
                            string[] splitter = webskins.Split(",".ToCharArray());
                            foreach (string thisSplitter in splitter)
                            {
                                if (thisSplitter.Length > 0)
                                {
                                    HierarchyObject.Add_Web_Skin(thisSplitter.ToLower());
                                }
                            }
                        }
                        break;

                    case "HI:CSS":
                        NodeReader.Read();
                        if (!String.IsNullOrEmpty(NodeReader.Value))
                        {
                            HierarchyObject.CSS_File = NodeReader.Value.Trim();
                        }
                        break;

                    case "HI:CUSTOMHOME":
                        NodeReader.Read();
                        // No longer do anything with this tag
                        // HierarchyObject.Custom_Home_Page_Source_File = NodeReader.Value.Trim();
                        break;

                    case "HI:FACETS":
                        NodeReader.Read();
                        string facets = NodeReader.Value;
                        if (!String.IsNullOrEmpty(facets))
                        {
                            string[] splitter2 = facets.Split(",".ToCharArray());
                            HierarchyObject.Clear_Facets();
                            foreach (string thisSplitter2 in splitter2)
                            {
                                HierarchyObject.Add_Facet(Convert.ToInt16(thisSplitter2));
                            }
                        }
                        break;

                    case "HI:MAPSEARCH":
                        if (NodeReader.MoveToAttribute("type"))
                        {
                            switch (NodeReader.GetAttribute("type").ToLower())
                            {
                            case "extent":
                            case "computed":
                                // This should already be set, assuming there were values to be added
                                if (HierarchyObject.Map_Search_Display == null)
                                {
                                    HierarchyObject.Map_Search_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.COMPUTED);
                                }
                                break;

                            case "fixed":
                                decimal latitude  = 999;
                                decimal longitude = 999;
                                int     zoom      = 999;

                                if (NodeReader.MoveToAttribute("latitude"))
                                {
                                    Decimal.TryParse(NodeReader.GetAttribute("latitude"), out latitude);
                                }
                                if (NodeReader.MoveToAttribute("longitude"))
                                {
                                    Decimal.TryParse(NodeReader.GetAttribute("longitude"), out longitude);
                                }
                                if (NodeReader.MoveToAttribute("zoom"))
                                {
                                    Int32.TryParse(NodeReader.GetAttribute("zoom"), out zoom);
                                }

                                if ((latitude != 999) && (longitude != 999))
                                {
                                    HierarchyObject.Map_Search_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.FIXED, zoom, longitude, latitude);
                                }
                                break;
                            }
                        }
                        break;

                    case "HI:MAPBROWSE":
                        if (NodeReader.MoveToAttribute("type"))
                        {
                            switch (NodeReader.GetAttribute("type").ToLower())
                            {
                            case "extent":
                                HierarchyObject.Map_Browse_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.EXTENT);
                                break;

                            case "computed":
                                HierarchyObject.Map_Browse_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.COMPUTED);
                                break;

                            case "fixed":
                                decimal latitude  = 999;
                                decimal longitude = 999;
                                int     zoom      = 999;

                                if (NodeReader.MoveToAttribute("latitude"))
                                {
                                    Decimal.TryParse(NodeReader.GetAttribute("latitude"), out latitude);
                                }
                                if (NodeReader.MoveToAttribute("longitude"))
                                {
                                    Decimal.TryParse(NodeReader.GetAttribute("longitude"), out longitude);
                                }
                                if (NodeReader.MoveToAttribute("zoom"))
                                {
                                    Int32.TryParse(NodeReader.GetAttribute("zoom"), out zoom);
                                }

                                if ((latitude != 999) && (longitude != 999))
                                {
                                    HierarchyObject.Map_Browse_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.FIXED, zoom, longitude, latitude);
                                }
                                break;
                            }
                        }
                        break;
                    }
                }

                if (NodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (NodeReader.Name.Trim().ToUpper() == "HI:SETTINGS")
                    {
                        return;
                    }
                }
            }
        }