Esempio n. 1
0
        public static string GetLibraryKey(XmlDocument doc)
        {
            var key = "";

            using (XmlReader reader = new XmlNodeReader(doc))
            {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        //return only when you have START tag
                        switch (reader.Name)
                        {
                        case "Directory":
                            if (reader.GetAttribute("title") == "library")
                            {
                                var localKey = reader.GetAttribute("key");
                                key = localKey;
                            }

                            break;
                        }
                    }
                }

                return(key);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="propertyDescriptor"></param>
        /// <param name="destination"></param>
        protected void DeserializeReferenceTypeData(XmlNodeReader reader, DbQueryPropertyDescriptor propertyDescriptor, object destination)
        {
            if (CanDeserialize(reader) && CanDeserialize(propertyDescriptor))
            {
                if (ObjectUtils.IsListType(propertyDescriptor.RetrunType))
                {
                    var _destination     = (propertyDescriptor.GetValue(destination) as IList) ?? ObjectUtils.CreateInstanceOf <IList>(propertyDescriptor.RetrunType);
                    var _destiDescriptor = OperationContext.DescriptorManager.GetDescriptor(_destination);

                    Deserialize(reader, _destiDescriptor.PropertyDescriptors, _destination);

                    propertyDescriptor.SetValue(destination, _destination);
                }
                else
                {
                    var _parentName      = reader.Name;
                    var _destination     = propertyDescriptor.GetValue(destination) ?? ObjectUtils.CreateInstanceOf(propertyDescriptor.RetrunType);
                    var _destiDescriptor = OperationContext.DescriptorManager.GetDescriptor(_destination);

                    while (reader.Read())
                    {
                        if (!(reader.NodeType.Equals(XmlNodeType.EndElement) &&
                              _parentName.Equals(reader.Name, StringComparison.CurrentCultureIgnoreCase)))
                        {
                            DeserializeValueTypeData(reader, _destiDescriptor.PropertyDescriptors, _destination);
                            continue;
                        }

                        propertyDescriptor.SetValue(destination, _destination);
                        break;
                    }
                }
            }
        }
Esempio n. 3
0
        private void readConfigFile()
        {
            string[] config = new string[5];

            int i = 0;

            //Create xml object
            XmlDocument xmlDOC = new XmlDocument();

            xmlDOC.Load("config.xml");
            XmlNodeReader readXML = new XmlNodeReader(xmlDOC);

            while (readXML.Read())
            {
                readXML.MoveToElement();                  //Forward
                if (readXML.NodeType == XmlNodeType.Text) //Only save config
                {
                    config[i] = readXML.Value;
                    i++;
                }
            }

            accessKeyId.Text       = config[0];
            accessKeySecret.Text   = config[1];
            recordId.Text          = config[2];
            fullDomainName.Text    = config[3];
            nextUpdateSeconds.Text = newSeconds.Text = config[4];
        }
Esempio n. 4
0
  public static void Main()
  {
    XmlNodeReader reader = null;

    try
    {
       //Create and load the XML document.
       XmlDocument doc = new XmlDocument();
       doc.LoadXml("<!-- sample XML -->" +
                   "<book>" +
                   "<title>Pride And Prejudice</title>" +
                   "<price>19.95</price>" +
                   "</book>");

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

       reader.MoveToContent(); //Move to the book node.
       reader.Read();  //Read the book start tag.
       reader.Skip();   //Skip the title element.

       Console.WriteLine(reader.ReadOuterXml());  //Read the price element.

     } 

     finally 
     {
        if (reader != null)
          reader.Close();
      }
  }
Esempio n. 5
0
        private static string GetConfigValue(XmlDocument doc, string path)
        {
            string  result = "";
            XmlNode child  = doc.SelectSingleNode(path);

            if (child != null)
            {
                XmlNodeReader nr = new XmlNodeReader(child);
                while (nr.Read())
                {
                    //					if (nr.Value != "")
                    if (!String.IsNullOrEmpty(nr.Value))
                    {
                        String delimeters = "\r\n ";
                        String outline    = nr.Value;
                        outline = outline.Trim(delimeters.ToCharArray());
                        //						if (outline != "")
                        if (!String.IsNullOrEmpty(outline))
                        {
                            result += outline;
                        }
                    }
                }
            }

            return(result);
        }
        private void LoadClassMapInformation(string xmlFile)
        {
            XmlDocument oXmlDocument = new XmlDocument();
            string      file         = xmlFile;

            try
            {
                oXmlDocument.Load(file);
                XmlNodeReader oXmlReader = new XmlNodeReader(oXmlDocument);
                while (oXmlReader.Read())
                {
                    if (oXmlReader.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }
                    if (oXmlReader.Name.ToLower() == "class")
                    {
                        ClassMap cls = GetClassMapInformation(oXmlReader);
                        if (cls != null)
                        {
                            m_ClassMaps.Add(cls.Name, cls);
                        }
                    }
                }
            }
            catch (PersistenceLayerException pException)
            {
                throw pException;
            }
            catch (Exception e)
            {
                string strErr = "Error:Read class mapping file" + file + "An error occurred,Please confirm your file path and format!" + e.Message;
                Assert.Fail(Error.XmlReadError, strErr);
            }
        }
Esempio n. 7
0
        private static List <VersionData.MopubNetworkData> GetMopubNetworkVersions()
        {
            var mopubNetworkVersions = new List <VersionData.MopubNetworkData>();

            var text = Resources.Load <TextAsset>("MopubNetworkInfo");

            if (text == null)
            {
                return(mopubNetworkVersions);
            }

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(text.text);

            using (XmlReader reader = new XmlNodeReader(xmlDoc))
            {
                while (reader.Read())
                {
                    if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "network"))
                    {
                        if (reader.HasAttributes)
                        {
                            var mopubNetworkData = new VersionData.MopubNetworkData(reader.GetAttribute("name") ?? "",
                                                                                    reader.GetAttribute("version") ?? "");
                            mopubNetworkVersions.Add(mopubNetworkData);
                        }
                    }
                }
            }

            return(mopubNetworkVersions);
        }
        public string getHospitalName()
        {
            string        StrNode         = "";
            string        StrHospitalName = "";
            XmlNodeReader reader          = null;

            XmlDoc.Load(FilePath);
            // 设定XmlNodeReader对象来打开XML文件
            reader = new XmlNodeReader(XmlDoc);
            // 读取XML文件中的数据,并显示出来
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    StrNode = reader.Name;
                    break;

                case XmlNodeType.Text:
                    if (StrNode.Equals("hospitalName"))
                    {
                        StrHospitalName = reader.Value;
                    }

                    break;
                }
            }
            return(Decodebase64(StrHospitalName));
        }
Esempio n. 9
0
 private static void move_to_node(XmlNodeReader nodeReader, string nodeName)
 {
     while ((nodeReader.Read()) && (nodeReader.Name.Trim() != nodeName))
     {
         // Do nothing here...
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Get track info for a list of users.
        /// </summary>
        /// <param name="userIDs">Array of user id's for which TrackInfo's should be returned.</param>
        /// <param name="dtUtcStart">Start UTC time stamp</param>
        /// <param name="dtUtcEnd">End UTC time stamp</param>
        /// <returns>List of XmlTrackInfo representations.</returns>
        public List <TrackInfo> GetTracksByUsers(int[] userIDs, DateTime dtUtcStart, DateTime dtUtcEnd)
        {
            List <TrackInfo> retTracks = new List <TrackInfo>();

            // Call Track WebService GetTracksByUsers
            XmlNode xmlResponse = m_Tracks.GetTracksByUsers(m_strSessionID, m_iApplicationID, userIDs, dtUtcStart, dtUtcEnd);

            // Check response for errors.
            CheckError(xmlResponse);

            // Deserialize the result into XmlTrackInfo representations.
            using (XmlReader reader = new XmlNodeReader(xmlResponse))
            {
                while (reader.Read())
                {
                    // Found a new trackInfo node to deserialize.
                    if (reader.Name == "trackInfo")
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(TrackInfo));

                        // Add the XmlTrackInfo representation to return list.
                        retTracks.Add((TrackInfo)serializer.Deserialize(reader.ReadSubtree()));
                    }
                }
            }

            return(retTracks);
        }
Esempio n. 11
0
        /// <summary>
        /// Get latest GateRecords for a user.
        /// </summary>
        /// <param name="iUserID">ID of the user.</param>
        /// <param name="bFilterNotUsed">Get only records created by the current device mapping.</param>
        /// <returns>List of XmlGateMessge representations.</returns>
        public List <GateMessage> GetLatestGateRecords(int iUserID, bool bFilterNotUsed)
        {
            List <GateMessage> retMessages = new List <GateMessage>();

            // Call Directory WebService GetLatestGateRecords
            XmlNode xmlResponse = m_Directory.GetLatestGateRecords(m_strSessionID, m_iApplicationID, iUserID, bFilterNotUsed);

            // Check Repsone for errors.
            CheckError(xmlResponse);

            // Deserialize the result into XmlGateMessage
            using (XmlReader reader = new XmlNodeReader(xmlResponse))
            {
                while (reader.Read())
                {
                    // Found a new gateMessage node to deserialize.
                    if (reader.Name == "gateMessage")
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(GateMessage));

                        // Add gateMessage representation to return list.
                        retMessages.Add((GateMessage)serializer.Deserialize(reader.ReadSubtree()));
                    }
                }
            }

            return(retMessages);
        }
Esempio n. 12
0
        /// <summary>
        /// Get all views.
        /// </summary>
        /// <returns>List of XmlView representations.</returns>
        public List <View> GetViews()
        {
            List <View> retViews = new List <View>();

            // Call Directory WebService GetViews
            XmlNode xmlResponse = m_Directory.GetViews(m_strSessionID, m_iApplicationID);

            // Check response for errors.
            CheckError(xmlResponse);

            // Desserialize the result into XmlViews
            using (XmlReader reader = new XmlNodeReader(xmlResponse))
            {
                while (reader.Read())
                {
                    // Found a new view node to desserialize.
                    if (reader.Name == "view")
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(View));

                        // Add view repsentation to return list.
                        retViews.Add((View)serializer.Deserialize(reader.ReadSubtree()));
                    }
                }
            }

            return(retViews);
        }
Esempio n. 13
0
        /// <summary>
        /// Return <see cref="Trip">Trips</see> for the given user and timespan.
        ///
        /// The <see cref="Trip">Trips</see> returned are splitted based by <see cref="XmlFatPoint" /> and <see cref="TrackInfo" /> data.
        /// </summary>
        /// <param name="iUserID">DB id of the user for which to get trips.</param>
        /// <param name="dtUtcStart">Start UTC date and time.</param>
        /// <param name="dtUtcEnd">End UTC date and time.</param>
        /// <returns></returns>
        public List <Trip> GetTripsByUser(int iUserID, DateTime dtUtcStart, DateTime dtUtcEnd)
        {
            List <Trip> retTrips = new List <Trip>();

            // Call Track WebService GetTripsByUser
            XmlNode xmlResponse = m_Tracks.GetTripsByUser(m_strSessionID, m_iApplicationID, iUserID, dtUtcStart, dtUtcEnd);

            // Check response for errors.
            CheckError(xmlResponse);

            // Deserialize the result into XmlTrip representations.
            using (XmlReader reader = new XmlNodeReader(xmlResponse))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Trip));
                while (reader.Read())
                {
                    // Found a new trip node to deserialize.
                    if (reader.Name == "trip")
                    {
                        Trip trip = (Trip)serializer.Deserialize(reader.ReadSubtree());
                        retTrips.Add(trip);
                    }
                }
            }

            return(retTrips);
        }
Esempio n. 14
0
        /// <summary>
        /// Get users for a given user template ID.
        /// </summary>
        /// <param name="iUserTemplateID">IDs of user template.</param>
        /// <returns>List of XmlUser representations.</returns>
        public List <User> GetUsersInUserTemplate(int iUserTemplateID)
        {
            List <User> retUsers = new List <User>();

            XmlNode xmlResponse = m_Directory.GetUsersInUserTemplate(m_strSessionID, m_iApplicationID, iUserTemplateID);

            // Check response for errors.
            CheckError(xmlResponse);

            // Desserialize the result into XmlUsers
            using (XmlReader reader = new XmlNodeReader(xmlResponse))
            {
                while (reader.Read())
                {
                    // Found a new user node to deserialize.
                    if (reader.Name == "user")
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(User));

                        // Add user representation to return list.
                        retUsers.Add((User)serializer.Deserialize(reader.ReadSubtree()));
                    }
                }
            }

            return(retUsers);
        }
  public static void Main() {
  
    XmlNodeReader reader = null;

    try {
               
        // Create and load an XmlDocument.
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<?xml version='1.0' ?>" +
                    "<!DOCTYPE book [<!ENTITY h 'hardcover'>]>" +
                    "<book>" +
                    "<title>Pride And Prejudice</title>" +
                    "<misc>&h;</misc>" +
                    "</book>");

        reader = new XmlNodeReader(doc);

        // Parse the file and display each node.
        while (reader.Read()) {
           if (reader.HasValue)
             Console.WriteLine("({0})  {1}={2}", reader.NodeType, reader.Name, reader.Value);
           else
             Console.WriteLine("({0}) {1}", reader.NodeType, reader.Name);
         }           
     }

     finally {
       if (reader!=null)
         reader.Close();
     }
  }
Esempio n. 16
0
        /// <summary> Reads the item aggregation configuration file and populates the new data into the
        /// item aggregation object </summary>
        /// <param name="HierarchyObject"> Item aggregation object to populate</param>
        /// <param name="FileLocation"> Full name of the item aggregation configuration XML file </param>
        public void Add_Info_From_XML_File(Item_Aggregation HierarchyObject, string FileLocation)
        {
            // Get the directory from the file location
            string directory = (new FileInfo(FileLocation)).DirectoryName;

            // Load this XML file
            XmlDocument hierarchyXml = new XmlDocument();

            hierarchyXml.Load(FileLocation);

            // create the node reader
            XmlNodeReader nodeReader = new XmlNodeReader(hierarchyXml);

            // Read all the nodes
            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:SETTINGS":
                        read_settings(nodeReader, HierarchyObject);
                        break;

                    case "HI:HOME":
                        read_home(nodeReader, HierarchyObject);
                        break;

                    case "HI:BANNER":
                        read_banners(nodeReader, HierarchyObject);
                        break;

                    case "HI:DIRECTIVES":
                        read_directives(nodeReader, HierarchyObject, directory);
                        break;

                    case "HI:HIGHLIGHTS":
                        read_highlights(nodeReader, HierarchyObject);
                        break;

                    case "HI:BROWSE":
                        read_browse(true, nodeReader, HierarchyObject);
                        break;

                    case "HI:INFO":
                        read_browse(false, nodeReader, HierarchyObject);
                        break;

                    case "HI:RESULTS":
                        read_results_specs(nodeReader, HierarchyObject);
                        break;
                    }
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Validates SOAP message from the stream specified.
        /// </summary>
        /// <param name="element"></param>
        /// <returns>True, if stream contains valid messages.</returns>
        public void Validate(XmlElement element)
        {
            XmlReader plainReader = new XmlNodeReader(element);

            while (plainReader.Read())
            {
                ;
            }
            plainReader.Close();
            if (_schemas != null)
            {
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ValidationType      = ValidationType.Schema;
                settings.Schemas.XmlResolver = null; //disable resolver - all schemas should be in place

                foreach (XmlSchema schema in _schemas.Schemas)
                {
                    settings.Schemas.Add(schema);
                }
                plainReader = new XmlNodeReader(element);
                XmlReader reader = XmlNodeReader.Create(plainReader, settings);

                while (reader.Read())
                {
                }
            }
        }
Esempio n. 18
0
    public static int LoadCount()
    {
        try
        {
            XmlDocument   doc = new XmlDocument();
            XmlNode       node;
            XmlNodeReader reader;
            doc.Load("Emails.xml");

            node   = doc.DocumentElement.SelectSingleNode("Count");
            reader = new XmlNodeReader(node);

            while (reader.Read())
            {
                switch (reader.Name)
                {
                case "I":
                {
                    string s = (string)reader.ReadString();
                    return((int)Convert.ToInt64(s));

                    break;
                }
                }
            }
        }
        catch
        {
            Console.WriteLine("Loading of emails.xml has failed!!!");
        }

        return(0);
    }
        public void NodeReaderMoveToNextAttributeWithSimpleXml()
        {
            XmlNodeReader nodeReader = NodeReaderTestHelper.CreateNodeReader("<root></root>");

            Assert.True(nodeReader.Read());
            Assert.False(nodeReader.MoveToNextAttribute());
        }
Esempio n. 20
0
        ///<summary>The problem with this is that if multiple copies of OD are open at the same time, it might get data from only the most recently opened database.  This won't work for some users, so we will normally dynamically alter the connection string.</summary>
        public static string GetODConnStr()
        {
            //return "Server=localhost;Database=development54;User ID=root;Password=;CharSet=utf8";
            XmlDocument document = new XmlDocument();
            string      path     = ODFileUtils.CombinePaths(Application.StartupPath, "FreeDentalConfig.xml");

            if (!File.Exists(path))
            {
                return("");
            }
            string computerName = "";
            string database     = "";
            string user         = "";
            string password     = "";

            try {
                document.Load(path);
                XmlNodeReader reader         = new XmlNodeReader(document);
                string        currentElement = "";
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        currentElement = reader.Name;
                    }
                    else if (reader.NodeType == XmlNodeType.Text)
                    {
                        switch (currentElement)
                        {
                        case "ComputerName":
                            computerName = reader.Value;
                            break;

                        case "Database":
                            database = reader.Value;
                            break;

                        case "User":
                            user = reader.Value;
                            break;

                        case "Password":
                            password = reader.Value;
                            break;
                        }
                    }
                }
                reader.Close();
            }
            catch {
                return("");
            }
            //example:
            //Server=localhost;Database=opendental;User ID=root;Password=;CharSet=utf8
            return("Server=" + computerName
                   + ";Database=" + database
                   + ";User ID=" + user
                   + ";Password="******";CharSet=utf8");
        }
Esempio n. 21
0
        private void process_constants(XmlNodeReader nodeReader, CompleteTemplate ThisCompleteTemplate)
        {
            // Read all the nodes
            while (nodeReader.Read())
            {
                // Get the node name, trimmed and to upper
                string nodeName = nodeReader.Name.Trim().ToUpper();

                // If this is the inputs or constant start tag, return
                if ((nodeReader.NodeType == XmlNodeType.EndElement) && (nodeName == "CONSTANTS"))
                {
                    return;
                }

                // If this is the beginning tag for an element, assign the next values accordingly
                if ((nodeReader.NodeType == XmlNodeType.Element) && (nodeName == "ELEMENT") && (nodeReader.HasAttributes))
                {
                    abstract_Element newConstant = process_element(nodeReader, -1);
                    if (newConstant != null)
                    {
                        newConstant.isConstant = true;
                        ThisCompleteTemplate.Add_Constant(newConstant);
                    }
                }
            }
        }
Esempio n. 22
0
        protected override void ProcessElement(BookData bookData, XmlReader xmlReader)
        {
            var xmlFragment = new XmlDocument();

            xmlFragment.Load(xmlReader);

            var publisher = new PublisherData();

            using (var tempReader = new XmlNodeReader(xmlFragment))
            {
                while (tempReader.Read())
                {
                    if (tempReader.NodeType == XmlNodeType.Element && tempReader.IsStartElement() &&
                        tempReader.LocalName.Equals("email"))
                    {
                        publisher.Email = GetInnerContentAsString(tempReader);
                    }
                }
            }

            using (var tempReader = new XmlNodeReader(xmlFragment))
            {
                publisher.Text = GetInnerContentAsString(tempReader);
            }

            bookData.Publisher = publisher;
        }
        private void LoadMapFileInformation()
        {
            XmlDocument oXmlDocument = new XmlDocument();
            string      file         = this.m_DatabaseXmlFile;

            Assert.VerifyNotEquals(file, "", Error.PesistentError, "Please set the configuration file");
            try
            {
                oXmlDocument.Load(file);
                XmlNodeReader oXmlReader = new XmlNodeReader(oXmlDocument);
                while (oXmlReader.Read())
                {
                    if (oXmlReader.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }
                    if (oXmlReader.Name.ToLower() == "ormappingfile")
                    {
                        if (oXmlReader.GetAttribute("path") != null)
                        {
                            m_ClassMapFiles.Add(oXmlReader.GetAttribute("path"));
                        }
                    }
                }
            }
            catch (PersistenceLayerException pException)
            {
                throw pException;
            }
            catch (Exception e)
            {
                string strErr = "Error:Read class mapping file " + file + "An error occurred,Please confirm you file path and format!" + e.Message;
                Assert.Fail(Error.XmlReadError, strErr);
            }
        }
Esempio n. 24
0
        public static string GetSectionKey(XmlDocument doc)
        {
            var key = "";

            LoggingHelpers.RecordGeneralEntry("Parsing XML Reply");
            using (XmlReader reader = new XmlNodeReader(doc))
            {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        LoggingHelpers.RecordGeneralEntry("Checking for directories");

                        switch (reader.Name)
                        {
                        case "Directory":
                            if (reader.GetAttribute("title") == "Library Sections")
                            {
                                var localKey = reader.GetAttribute("key");
                                key = localKey;
                                LoggingHelpers.RecordGeneralEntry("Found " + key);
                            }

                            break;
                        }
                    }
                }

                return(key);
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Deserializes the data from the reader into a strongly type ConfigurationSection or class
        /// </summary>
        /// <param name="xmlNode">The XmlNode containing the serilized data.</param>
        /// <param name="section">Section that is being deserialized</param>
        private static void deserializeTypedSection(XmlNode xmlNode, Section section)
        {
            var dynSection = DynamicInstance.CreateInstance(section.Assembly, section.Type);

            if (dynSection != null)
            {
                var reader = new XmlNodeReader(xmlNode);

                if (dynSection is ConfigurationSection)
                {
                    var deserializeSection = dynSection.GetType().GetMethod("DeserializeSection",
                                                                            BindingFlags.Instance | BindingFlags.NonPublic |
                                                                            BindingFlags.FlattenHierarchy);
                    deserializeSection.Invoke(dynSection, new object[] { reader });
                    section.Data = dynSection;
                }
                else
                {
                    reader.Read();
                    reader.MoveToContent();

                    var xRoot = new XmlRootAttribute(xmlNode.Name);

                    var serializer = new XmlSerializer(dynSection.GetType(), xRoot);
                    section.Data = serializer.Deserialize(reader);
                }
            }
        }
        private void process_entity_tag_and_project(XmlNodeReader nodeReader, SobekCM_Item thisPackage)
        {
            // Process the attributes on the entityDesc
            int attributes = nodeReader.AttributeCount;

            for (int i = 0; i < attributes; i++)
            {
                // Go to this attribute
                nodeReader.MoveToAttribute(i);

                // If this is type, save it
                if (nodeReader.Name.Trim().ToUpper() == "TYPE")
                {
                    thisPackage.Bib_Info.Type.Add_Uncontrolled_Type(nodeReader.Value.Trim());
                }

                // If this is the source code, save that
                if (nodeReader.Name.Trim().ToUpper() == "SOURCE")
                {
                    thisPackage.Bib_Info.Source.Code      = nodeReader.Value.Trim();
                    thisPackage.Bib_Info.Source.Statement = nodeReader.Value.Trim();
                }
            }

            // Read the project code.. first being the primary
            move_to_node(nodeReader, "projects");

            // Get the text from this node
            nodeReader.Read();
            string projectText = nodeReader.Value.Trim();

            thisPackage.Behaviors.Add_Aggregation(projectText);
        }
Esempio n. 27
0
  public static void Main()
  {
    XmlNodeReader reader = null;

    try
    {           
        //Create and load an XmlDocument.
        XmlDocument doc = new XmlDocument();
        doc.Load("http://localhost/uri.xml");

        reader = new XmlNodeReader(doc);

        //Parse the file and display the base URI for each node.
        while (reader.Read())
        {
            Console.WriteLine("({0}) {1}", reader.NodeType, reader.BaseURI);
         }           
     }

     finally
     {
       if (reader!=null)
         reader.Close();
     }
  }
Esempio n. 28
0
        /// <summary>
        /// Loads the image editors.
        /// </summary>
        public static void Load()
        {
            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml(Properties.Settings.Default.Editors);

            XmlNodeList xeditors = xdoc.SelectNodes(EDITOR_XPATH);

            foreach (XmlNode xeditor in xeditors)
            {
                Editor        editor  = new Editor();
                XmlNodeReader xreader = new XmlNodeReader(xeditor);

                while (xreader.Read())
                {
                    if (xreader.IsStartElement())
                    {
                        switch (xreader.Name)
                        {
                        case EDITOR_NAME:
                            xreader.Read();
                            editor.Name = xreader.Value;
                            break;

                        case EDITOR_APPLICATION:
                            xreader.Read();
                            editor.Application = xreader.Value;
                            break;

                        case EDITOR_ARGUMENTS:
                            xreader.Read();
                            editor.Arguments = xreader.Value;
                            break;
                        }
                    }
                }

                xreader.Close();

                if (!string.IsNullOrEmpty(editor.Name) &&
                    !string.IsNullOrEmpty(editor.Application) &&
                    !string.IsNullOrEmpty(editor.Arguments))
                {
                    Add(editor);
                }
            }
        }
Esempio n. 29
0
        private List <string> GetPageLinks(XmlDocument doc)
        {
            List <string> links  = new List <string>();
            XmlReader     reader = new XmlNodeReader(doc);

            // Look for <loc> and <a> tags
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name.ToLower() == "loc")
                    {
                        if (reader.Read() && IsLinkAllowed(reader.Value))
                        {
                            links.Add(reader.Value.ToLower().Trim());
                        }
                    }
                    else if (reader.Name.ToLower() == "a")
                    {
                        if (reader.HasAttributes)
                        {
                            while (reader.MoveToNextAttribute())
                            {
                                if (reader.Name.ToLower() == "href")
                                {
                                    string URL = reader.Value.ToLower();
                                    if (URL[0] == '/')
                                    {
                                        // Append relative path to domain
                                        URL = crawlURL + URL.Substring(1, URL.Length - 1);
                                    }

                                    if (IsLinkAllowed(URL))
                                    {
                                        links.Add(URL);
                                    }
                                }
                                break;
                            }
                            reader.MoveToElement();
                        }
                    }
                }
            }

            return(links);
        }
Esempio n. 30
0
        private void listsService_GetListItemsCompleted(object sender, SharePointDemo.SharePointLists.GetListItemsCompletedEventArgs e)
        {
            // Get the services
            SharePointLists.Lists listsService = sender as SharePointLists.Lists;

            // Unhook from the event
            listsService.GetListItemsCompleted -= new SharePointDemo.SharePointLists.GetListItemsCompletedEventHandler(listsService_GetListItemsCompleted);

            // Check if we caneled
            if (e.Cancelled || _canceled || e.Error != null)
            {
                if (e.Error != null)
                {
                    // Stop the animation and show the error
                    _busyProgressBar.MarqueeAnimationSpeed = 0;
                    Application.DoEvents();
                    Messager.ShowError(this, e.Error);
                }

                // Cancel
                listsService.Dispose();
                _isBusy      = false;
                DialogResult = DialogResult.Cancel;
                return;
            }

            // We are done, get the results
            XmlNode listItemsNode = e.Result;

            // Loop through all the items, get the documents
            _documentNames = new List <string>();
            XmlNodeList childNodes = listItemsNode.ChildNodes;

            foreach (XmlNode childNode in childNodes)
            {
                XmlNodeReader reader = new XmlNodeReader(childNode);

                while (reader.Read())
                {
                    if (reader["ows_EncodedAbsUrl"] != null && reader["ows_LinkFilename"] != null)
                    {
                        string objType = reader["ows_FSObjType"].ToString();

                        // If the objType is of this format: number;#1 then it is a folder
                        // and we should not use it
                        if (!objType.EndsWith(";#1"))
                        {
                            // Get the file name
                            string fileName = reader["ows_LinkFilename"].ToString();
                            _documentNames.Add(fileName);
                        }
                    }
                }
            }

            listsService.Dispose();
            DialogResult = DialogResult.OK;
            _isBusy      = false;
        }