当前位置: 首页>>代码示例>>C#>>正文


C# System.Xml.XmlTextReader.ReadString方法代码示例

本文整理汇总了C#中System.Xml.XmlTextReader.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextReader.ReadString方法的具体用法?C# System.Xml.XmlTextReader.ReadString怎么用?C# System.Xml.XmlTextReader.ReadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlTextReader的用法示例。


在下文中一共展示了System.Xml.XmlTextReader.ReadString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsolatedStorage_Read_and_Write_Sample

        public static void IsolatedStorage_Read_and_Write_Sample()
        {
            string fileName = @"SelfWindow.xml";

            IsolatedStorageFile storFile = IsolatedStorageFile.GetUserStoreForDomain();
            IsolatedStorageFileStream storStream = new IsolatedStorageFileStream(fileName, FileMode.Create, FileAccess.Write);
            System.Xml.XmlWriter writer = new System.Xml.XmlTextWriter(storStream, Encoding.UTF8);
            writer.WriteStartDocument();

            writer.WriteStartElement("Settings");

            writer.WriteStartElement("UserID");
            writer.WriteValue(42);
            writer.WriteEndElement();
            writer.WriteStartElement("UserName");
            writer.WriteValue("kingwl");
            writer.WriteEndElement();

            writer.WriteEndElement();

            writer.Flush();
            writer.Close();
            storStream.Close();

            string[] userFiles = storFile.GetFileNames();

            foreach(var userFile in userFiles)
            {
                if(userFile == fileName)
                {
                    var storFileStreamnew =  new IsolatedStorageFileStream(fileName,FileMode.Open,FileAccess.Read);
                    StreamReader storReader = new StreamReader(storFileStreamnew);
                    System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(storReader);

                    int UserID = 0;
                    string UserName = null;

                    while(reader.Read())
                    {
                        switch(reader.Name)
                        {
                            case "UserID":
                                UserID = int.Parse(reader.ReadString());
                                break;
                            case "UserName":
                                UserName = reader.ReadString();
                                break;
                            default:
                                break;
                        }
                    }

                    Console.WriteLine("{0} {1}", UserID, UserName);

                    storFileStreamnew.Close();
                }
            }
            storFile.Close();
        }
开发者ID:xxy1991,项目名称:cozy,代码行数:59,代码来源:D8IsolatedStorageReadAndWrite.cs

示例2: listMetadataFormats

        public ListMetadataFormats listMetadataFormats(string sidentifier)
        {
            System.IO.Stream objStream;
            ListMetadataFormats objFormat = new ListMetadataFormats();
            System.Net.HttpWebRequest wr;
            System.Xml.XmlTextReader rd;

            if (sidentifier.Length == 0)
            {
                prequestURL = baseURL + "?verb=ListMetadataFormats";
            }
            else
            {
                prequestURL = baseURL + "?verb=ListMetadataFormats&identifier=" + sidentifier;
            }

            try
            {
                wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
                wr.UserAgent = cUserAgent;
                System.Net.WebResponse response = wr.GetResponse();
                objStream = response.GetResponseStream();
                System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
                prawXML = reader.ReadToEnd();
                reader.Close();
                rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
            }
            catch (Exception e)
            {
                error.errorName = e.ToString();
                error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
                return null;
            }

            while (rd.Read())
            {
                if (rd.NodeType == System.Xml.XmlNodeType.Element)
                {
                    if (rd.Name == "responseDate")
                    {
                        presponseDate = rd.ReadString();
                    }
                    else if (rd.Name == "ListMetadataFormats")
                    {
                        while (rd.Read())  // && rd.NodeType != System.Xml.XmlNodeType.EndElement)
                        {
                            switch (rd.Name)
                            {
                                case "metadataPrefix":
                                    objFormat.metadataPrefix.Add(ParseOAI(ref rd, "metadataPrefix"));
                                    break;
                                case "schema":
                                    objFormat.schema.Add(ParseOAI(ref rd, "schema"));
                                    break;
                                case "metadataNamespace":
                                    objFormat.metadataNamespace.Add(ParseOAI(ref rd, "metadataNamespace"));
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                    else if (rd.Name == "error")
                    {
                        error.errorName = rd.GetAttribute("code");
                        error.errorDescription = rd.ReadString();
                        return null;
                    }
                }
            }

            rd.Close();
            return objFormat;
        }
开发者ID:rodricios,项目名称:OaiHarvestAndStore,代码行数:74,代码来源:oai.cs

示例3: ListIdentifiers

        public ListIdentifier ListIdentifiers(string sPrefix,
            string sset,
            string sfrom,
            string suntil,
            ResumptionToken objToken)
        {
            System.IO.Stream objStream;
            ListIdentifier objList = new ListIdentifier();
            Identifiers objRecord;
            ResumptionToken myToken;
            string tmp = "";
            System.Net.HttpWebRequest wr;
            System.Xml.XmlTextReader rd;

            if (sPrefix.Length == 0)
            {
                sPrefix = "oai_dc";
            }

            if (objToken == null)
            {
                if (sset.Length != 0)
                {
                    sset = "&set=" + sset;
                }
                if (sfrom.Length != 0)
                {
                    sfrom = "&from=" + sfrom;
                }
                if (suntil.Length != 0)
                {
                    suntil = "&until=" + suntil;
                }

                prequestURL = baseURL + "?verb=ListIdentifiers&metadataPrefix=" + sPrefix + sset + sfrom + suntil;

            }
            else
            {
                prequestURL = baseURL + "?verb=ListIdentifiers&resumptionToken=" + objToken.resumptionToken;
                //This is where we handle the resumptionToken
            }
            //======================================================
            // If you wanted to support additional metadata formats,
            // you would just need to have additional handlers.
            //======================================================
            //Console.Write(sURL);
            try
            {
                wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
                wr.UserAgent = cUserAgent;
                System.Net.WebResponse response = wr.GetResponse();
                objStream = response.GetResponseStream();
                System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
                prawXML = reader.ReadToEnd();
                reader.Close();
                rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
            }
            catch (Exception e)
            {
                error.errorName = "badConnection";
                error.errorDescription = e.Message + "<br>Unable to connect to " + baseURL;
                return null;
            }

            while (rd.Read())
            {
                if (rd.NodeType == System.Xml.XmlNodeType.Element)
                {
                    if (rd.Name == "responseDate")
                    {
                        presponseDate = rd.ReadString();
                    }
                    else if (rd.Name == "ListIdentifiers")
                    {
                        do
                        {
                            if (rd.Name == "header")
                            {
                                tmp = rd.ReadOuterXml();
                                //tmp += ParseOAIContainer(ref rd, "header", true);
                                //Console.WriteLine("In the Function: " + tmp);
                                objRecord = new Identifiers(tmp);
                                objList.record.Add(objRecord);
                                //return objRecord;
                            }
                            else if (rd.Name == "resumptionToken")
                            {
                                tmp = rd.ReadOuterXml();
                                myToken = new ResumptionToken(tmp);
                                objList.token = myToken;
                            }
                            else rd.Read(); // Added the Read() and will never occur with the ReadInnerXml()

                        } while (rd.Name != "ListIdentifiers"); // loop
                    }
                    else if (rd.Name == "error")
                    {
                        error.errorName = rd.GetAttribute("code");
                        error.errorDescription = rd.ReadString();
//.........这里部分代码省略.........
开发者ID:rodricios,项目名称:OaiHarvestAndStore,代码行数:101,代码来源:oai.cs

示例4: identify

        //=======================================================================
        // Sub/Function: identify
        // Description: Use this function to return the identifier information
        // from an OAI repository.
        //
        // example:
        // OAI objOAI = new OAI("http://memory.loc.gov/cgi-bin/oai2_0");
        // Identify objID = new Identify();
        //
        // objID = objOAI.identify();
        // Console.WriteLine("Base URL: " + objID.baseURL);
        // Console.WriteLine("Repository: " + objID.repositoryName);
        // Console.WriteLine("Deleted Records: "  + objID.deletedRecord);
        //=======================================================================
        public Identify identify()
        {
            System.IO.Stream objStream;
            Identify objID = new Identify();
            System.Net.HttpWebRequest wr;
            System.Xml.XmlTextReader rd;

            try
            {
                prequestURL = baseURL + "?verb=Identify";
                wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
                wr.UserAgent = cUserAgent;
                System.Net.WebResponse response = wr.GetResponse();
                objStream = response.GetResponseStream();
                System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
                prawXML = reader.ReadToEnd();
                reader.Close();
                rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
            }
            catch (Exception e)
            {
                error.errorName = e.ToString();
                error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
                return null;
            }

            while (rd.Read())
            {
                if (rd.NodeType == System.Xml.XmlNodeType.Element)
                {
                    if (rd.Name == "responseDate")
                    {
                        presponseDate = rd.ReadString();
                    }
                    else if (rd.Name == "Identify")
                    {
                        while (rd.Read() && rd.NodeType != System.Xml.XmlNodeType.EndElement)
                        {
                            switch (rd.Name)
                            {
                                case "repositoryName":
                                    objID.repositoryName = ParseOAI(ref rd, "repositoryName");
                                    break;
                                case "baseURL":
                                    objID.baseURL = ParseOAI(ref rd, "baseURL");
                                    break;
                                case "protocolVersion":
                                    objID.protocolVersion = ParseOAI(ref rd, "protocolVersion");
                                    break;
                                case "earliestDatestamp":
                                    objID.earliestDatestamp = ParseOAI(ref rd, "earliestDatestamp");
                                    break;
                                case "deletedRecord":
                                    objID.deletedRecord = ParseOAI(ref rd, "deletedRecord");
                                    break;
                                case "granularity":
                                    objID.granularity = ParseOAI(ref rd, "granularity");
                                    break;
                                case "adminEmail":
                                    objID.adminEmail.Add(ParseOAI(ref rd, "adminEmail"));
                                    break;
                                case "compression":
                                    objID.compression.Add(ParseOAI(ref rd, "compression"));
                                    break;
                                case "description":
                                    objID.description.Add(ParseOAIContainer(ref rd, "description"));
                                    break;
                            }
                        }
                    }
                    else if (rd.Name == "error")
                    {
                        error.errorName = rd.GetAttribute("code");
                        error.errorDescription = rd.ReadString();
                        return null;
                    }
                }
            }

            rd.Close();

            return objID;
        }
开发者ID:rodricios,项目名称:OaiHarvestAndStore,代码行数:97,代码来源:oai.cs

示例5: GetRecord

        public Record GetRecord(string sidentifier, string sPrefix, ref Object objHandler)
        {
            System.IO.Stream objStream;
            Record objRecord;
            string tmp = "";
            System.Net.HttpWebRequest wr;
            System.Xml.XmlTextReader rd;

            if (sPrefix.Length == 0)
            {
                sPrefix = "oai_dc";
            }

            prequestURL = baseURL + "?verb=GetRecord&metadataPrefix=" + sPrefix + "&identifier=" + sidentifier;

            //======================================================
            // If you wanted to support additional metadata formats,
            // you would just need to have additional handlers.
            //======================================================

            try
            {
                wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
                wr.UserAgent = cUserAgent;
                System.Net.WebResponse response = wr.GetResponse();
                objStream = response.GetResponseStream();
                System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
                prawXML = reader.ReadToEnd();
                reader.Close();
                rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
            }
            catch (Exception e)
            {
                error.errorName = e.ToString();
                error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
                return null;
            }

            while (rd.Read())
            {
                if (rd.NodeType == System.Xml.XmlNodeType.Element)
                {
                    if (rd.Name == "responseDate")
                    {
                        presponseDate = rd.ReadString();
                    }
                    else if (rd.Name == "GetRecord")
                    {
                        do
                        {
                            if (rd.Name == "record")
                            {
                                tmp = ParseOAIContainer(ref rd, "record");
                                objRecord = new Record(tmp, ref objHandler);
                                return objRecord;
                            }
                            else rd.Read(); // Added the Read() and will never occur with the ReadInnerXml()

                        } while (rd.Name != "GetRecord"); // loop
                    }
                    else if (rd.Name == "error")
                    {
                        error.errorName = rd.GetAttribute("code");
                        error.errorDescription = rd.ReadString();
                        return null;
                    }
                }
            }

            return null;
        }
开发者ID:rodricios,项目名称:OaiHarvestAndStore,代码行数:71,代码来源:oai.cs

示例6: ResumptionToken

 public ResumptionToken(string sXML)
 {
     System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sXML, System.Xml.XmlNodeType.Element, null);
     while (reader.Read())
     {
         if (reader.Name == "resumptionToken")
         {
             expirationDate = reader.GetAttribute("expirationDate");
             completeListSize = reader.GetAttribute("completeListSize");
             cursor = reader.GetAttribute("cursor");
             resumptionToken = reader.ReadString();
         }
     }
 }
开发者ID:rodricios,项目名称:OaiHarvestAndStore,代码行数:14,代码来源:oai.cs

示例7: OAI_LIST

        public OAI_LIST(string sXML, ref Object objHandler)
        {
            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sXML, System.Xml.XmlNodeType.Element, null);
            while (reader.Read())
            {
                if (reader.Name == "setSpec")
                {
                    setSpec = reader.ReadString();
                }
                else if (reader.Name == "setName")
                {
                    setName = reader.ReadString();
                }
                else if (reader.Name == "setDescription")
                {
                    Type theHandlerType = Type.GetType(objHandler.ToString());
                    Object[] tobject = new object[1];
                    tobject[0] = reader.ReadInnerXml();

                    description = theHandlerType.InvokeMember("", BindingFlags.DeclaredOnly |
                        BindingFlags.Public | BindingFlags.NonPublic |
                        BindingFlags.Instance | BindingFlags.CreateInstance, null, null, tobject);
                }
            }
        }
开发者ID:rodricios,项目名称:OaiHarvestAndStore,代码行数:25,代码来源:oai.cs

示例8: OAI_Header

        public OAI_Header(string sXML)
        {
            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sXML, System.Xml.XmlNodeType.Element, null);
            while (reader.Read() && reader.Name != "header") ;  // Keep searching until finding header

            if (reader.Name == "header")
            {
                status = reader.GetAttribute("status");

                while (reader.Read())
                {
                    switch (reader.Name)
                    {
                        case "identifier":
                            if (identifier.Length == 0)   // In case this is the DC indentifier
                                identifier = reader.ReadString();
                            break;
                        case "datestamp":
                            datestamp = reader.ReadString();
                            break;
                        case "setSpec":
                            setSpec.Add(reader.ReadString());
                            break;
                    }
                }
            }
        }
开发者ID:rodricios,项目名称:OaiHarvestAndStore,代码行数:27,代码来源:oai.cs

示例9: OAI_DC

        public OAI_DC(string sXML)
        {
            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sXML, System.Xml.XmlNodeType.Element, null);
            while (reader.Read() && reader.Name != "oai_dc:dc" && reader.Name != "oaidc:dc") ;  // Keep reading until finding oia_dc

            string oiaDCxml = reader.ReadInnerXml();

            reader = new System.Xml.XmlTextReader(oiaDCxml, System.Xml.XmlNodeType.Element, null);

            while (reader.Read())
            {
                string metadata = reader.Name.Replace("dc:", "");  // Remove optional dc:
                switch (metadata)
                {
                    case "title":
                        title.Add(reader.ReadString());
                        break;
                    case "creator":
                        creator.Add(reader.ReadString());
                        break;
                    case "subject":
                        subject.Add(reader.ReadString());
                        break;
                    case "description":
                        description.Add(reader.ReadString());
                        break;
                    case "publisher":
                        publisher.Add(reader.ReadString());
                        break;
                    case "contributor":
                        contributor.Add(reader.ReadString());
                        break;
                    case "date":
                        date.Add(reader.ReadString());
                        break;
                    case "type":
                        type.Add(reader.ReadString());
                        break;
                    case "format":
                        format.Add(reader.ReadString());
                        break;
                    case "identifier":
                        identifier.Add(reader.ReadString());
                        break;
                    case "source":
                        source.Add(reader.ReadString());
                        break;
                    case "language":
                        language.Add(reader.ReadString());
                        break;
                    case "relation":
                        relation.Add(reader.ReadString());
                        break;
                    case "coverage":
                        coverage.Add(reader.ReadString());
                        break;
                    case "rights":
                        rights.Add(reader.ReadString());
                        break;
                    default:
                        break;
                }
            } // end while
        }
开发者ID:rodricios,项目名称:OaiHarvestAndStore,代码行数:64,代码来源:oai.cs

示例10: ListSets

        public ListSet ListSets(ResumptionToken objToken, ref Object objHandler)
        {
            System.IO.Stream objStream;
            OAI_LIST objRecord;
            ListSet objList = new ListSet();
            ResumptionToken myToken;
            string tmp = "";
            System.Net.HttpWebRequest wr;
            System.Xml.XmlTextReader rd;

            if (objToken == null)
            {
                prequestURL = baseURL + "?verb=ListSets";
            }
            else
            {
                prequestURL = baseURL + "?verb=ListSets&resumptionToken=" + objToken.resumptionToken;
                //This is where we handle the resumptionToken
            }
            //======================================================
            // If you wanted to support additional metadata formats,
            // you would just need to have additional handlers.
            //======================================================

            try
            {
                wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
                wr.UserAgent = cUserAgent;
                System.Net.WebResponse response = wr.GetResponse();
                objStream = response.GetResponseStream();
                System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
                prawXML = reader.ReadToEnd();
                reader.Close();
                rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
            }
            catch (Exception e)
            {
                error.errorName = e.ToString();
                error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
                return null;
            }

            while (rd.Read())
            {
                if (rd.NodeType == System.Xml.XmlNodeType.Element)
                {
                    if (rd.Name == "responseDate")
                    {
                        presponseDate = rd.ReadString();
                    }
                    else if (rd.Name == "ListSets")
                    {
                        //while (rd.Read())
                        do
                        {
                            if (rd.Name == "set")
                            {
                                objRecord = new OAI_LIST(rd.ReadInnerXml(), ref objHandler);
                                objList.listset.Add(objRecord);
                                //return objRecord;
                            }
                            else if (rd.Name == "resumptionToken")
                            {
                                tmp = rd.ReadOuterXml();
                                myToken = new ResumptionToken(tmp);
                                objList.token = myToken;
                            }
                            else rd.Read(); // Added the Read() and will never occur with the ReadInnerXml()

                        } while (rd.Name != "ListSets"); // loop
                    }
                    else if (rd.Name == "error")
                    {
                        error.errorName = rd.GetAttribute("code");
                        error.errorDescription = rd.ReadString();
                        return null;
                    }
                }
            }

            rd.Close();
            return objList;
        }
开发者ID:rodricios,项目名称:OaiHarvestAndStore,代码行数:83,代码来源:oai.cs

示例11: Process_SRU

        private System.Collections.ArrayList Process_SRU(string xml)
        {
            System.Xml.XmlTextReader rd;
            System.Collections.ArrayList tp = new System.Collections.ArrayList();

            System.Xml.XmlDocument objDoc = new System.Xml.XmlDocument();
            objDoc.XmlResolver = null;
            System.Xml.XmlNamespaceManager Manager = new System.Xml.XmlNamespaceManager(objDoc.NameTable);
            System.Xml.XmlNodeList objNodes;
            string RetrievedRecords = "0";
            System.Collections.ArrayList RecordSet = new System.Collections.ArrayList();

            rd = new System.Xml.XmlTextReader(xml, System.Xml.XmlNodeType.Document, null);
            string RecordPosition = "1";

            while (rd.Read())
            {
                if (rd.NodeType == System.Xml.XmlNodeType.Element)
                {
                    if (rd.Name.IndexOf("numberOfRecords") > -1)
                    {
                        RetrievedRecords = rd.ReadString();
                    }
                    if (rd.Name.IndexOf("recordData") > -1)
                    {
                        RecordSet.Add(rd.ReadInnerXml());
                        //this needs to go somewhere
                    }
                    if (rd.Name.IndexOf("recordPosition") > -1)
                    {
                        RecordPosition = rd.ReadString();
                    }
                }
            }

            rd.Close();

            for (int x = 0; x < RecordSet.Count; x++)
            {
                struct_Records st_recs = new struct_Records();
                st_recs.xml = (string)RecordSet[x];

                Manager.AddNamespace("marc", "http://www.loc.gov/MARC21/slim");
                //try
                //{
                objDoc.LoadXml((string)RecordSet[x]);
                objNodes = objDoc.SelectNodes("marc:record/marc:datafield[@tag='150']", Manager);
                if (objNodes == null)
                {
                    objNodes = objDoc.SelectNodes("record/datafield[@tag='150']", Manager);
                }
                foreach (System.Xml.XmlNode objNode in objNodes)
                {
                    st_recs.xml = objNode.InnerXml;

                    System.Xml.XmlNodeList codes = objNode.SelectNodes("marc:subfield", Manager);
                    if (codes == null)
                    {
                        codes = objNode.SelectNodes("subfield", Manager);
                    }

                    foreach (System.Xml.XmlNode objN in codes)
                    {
                        st_recs.display += objN.InnerText + " -- ";
                        st_recs.main += "$" + objN.Attributes["code"].InnerText + objN.InnerText;
                    }

                    if (st_recs.display != null)
                    {
                        st_recs.display = st_recs.display.TrimEnd(" -".ToCharArray());
                    }
                    else
                    {
                        st_recs.display = "";
                    }

                }

                if (objNodes.Count <= 0)
                {

                    st_recs.main = "Undefined";
                    st_recs.xml = "<undefined>undefined</undefined>";
                }
                //}
                //catch
                //{
                //    return null;
                //}
                tp.Add(st_recs);
            }

            RecordCount = System.Convert.ToInt32(RetrievedRecords);
            return tp;
        }
开发者ID:reeset,项目名称:oclc_api,代码行数:95,代码来源:oclc_api_search.cs

示例12: GetBasic

 /// <summary>
 /// Gets basic event information.
 /// </summary>
 /// <param name="log">The event's log.</param>
 /// <param name="source">The event's source. Can be <c>null</c>.</param>
 /// <param name="eventId">The event's id. Can be <c>null</c>.</param>
 /// <returns><c>true</c> if subscription represents a basic event, <c>false</c> if not.</returns>
 public bool GetBasic(out string log, out string source, out int? eventId)
 {
     log = source = null;
     eventId = null;
     if (!string.IsNullOrEmpty(this.Subscription))
     {
         using (System.IO.MemoryStream str = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(this.Subscription)))
         {
             using (System.Xml.XmlTextReader rdr = new System.Xml.XmlTextReader(str))
             {
                 rdr.MoveToContent();
                 rdr.ReadStartElement("QueryList");
                 if (rdr.Name == "Query" && rdr.MoveToAttribute("Path"))
                 {
                     string path = rdr.Value;
                     if (rdr.MoveToElement() && rdr.ReadToDescendant("Select") && path.Equals(rdr["Path"], StringComparison.InvariantCultureIgnoreCase))
                     {
                         string content = rdr.ReadString();
                         System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(content,
                             @"\*(?:\[System\[(?:Provider\[\@Name='(?<s>[^']+)'\])?(?:\s+and\s+)?(?:EventID=(?<e>\d+))?\]\])",
                             System.Text.RegularExpressions.RegexOptions.IgnoreCase |
                             System.Text.RegularExpressions.RegexOptions.Compiled |
                             System.Text.RegularExpressions.RegexOptions.Singleline |
                             System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace);
                         if (m.Success)
                         {
                             log = path;
                             if (m.Groups["s"].Success)
                                 source = m.Groups["s"].Value;
                             if (m.Groups["e"].Success)
                                 eventId = Convert.ToInt32(m.Groups["e"].Value);
                             return true;
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:hpie,项目名称:hpie,代码行数:47,代码来源:Trigger.cs

示例13: ListRecords


//.........这里部分代码省略.........
                if (ee.Status == System.Net.WebExceptionStatus.ProtocolError)
                {
                    var response = ee.Response as System.Net.HttpWebResponse;
                    if (response != null)
                    {
                        if ((int)response.StatusCode == 503)
                        {
                            string retryafter = response.Headers["Retry-After"];
                            if (retryafter != null && IsNumeric(retryafter) == true)
                            {
                                {
                                    sleepval = System.Convert.ToInt32(retryafter) * 1000;
                                }
                            }
                        }
                    }

                    if (fail <= 4)
                    {
                        //System.Windows.Forms.MessageBox.Show(sleepval.ToString());
                        System.Threading.Thread.Sleep(sleepval);
                        goto Restart;
                    }
                    else
                    {
                        wr.Abort();
                        error.errorName = ee.ToString();
                        error.errorDescription = ee.Message + "\n<br>Unable to connect to " + baseURL;
                        return null;
                    }
                }
            }
            catch (Exception e)
            {
               // System.Windows.Forms.MessageBox.Show("2");
                if (wr != null)
                {
                    wr.Abort();
                }
                error.errorName = e.ToString();
                error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
                return null;
            }

            fail = 0;
			while (rd.Read()) 
			{
				if (rd.NodeType == System.Xml.XmlNodeType.Element) 
				{
					if (rd.Name == "responseDate")
					{
						presponseDate = rd.ReadString();
					}
					else if (rd.Name=="ListRecords") 
					{ 
						do 
						{
                            
							if (rd.Name=="record") 
							{
								tmp = ParseOAIContainer(ref rd, "record");
								objRecord = new Record(tmp,ref objHandler);
								objList.record.Add(objRecord);
								//return objRecord;
							} 
							else if (rd.Name=="resumptionToken") 
							{
								tmp=rd.ReadOuterXml();
								myToken = new ResumptionToken(tmp);
								objList.token = myToken;
							}
                            //else if (rd.Name.ToLower() == "OAI-PMH".ToLower())
                            //{
                            //    break;
                            //}
                            else if (rd.EOF == true)
                            {
                                error.errorName = "Empty ListRecords Request";
                                error.errorDescription = "No data was returned in the ListRecords Element.  This is likely an error.";
                                return null;
                            }
                            else rd.Read(); // Added the Read() and will never occur with the ReadInnerXml()

						} while (rd.Name!="ListRecords"); // loop
					} 
					else if (rd.Name=="error") 
					{
						error.errorName = rd.GetAttribute("code");
						error.errorDescription = rd.ReadString();
						return null;
					}
				}
			}

            
            return objList;
            

			
		}
开发者ID:reeset,项目名称:oai.cs,代码行数:101,代码来源:oai.cs


注:本文中的System.Xml.XmlTextReader.ReadString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。