本文整理汇总了C#中System.Xml.XmlTextReader.ReadOuterXml方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextReader.ReadOuterXml方法的具体用法?C# System.Xml.XmlTextReader.ReadOuterXml怎么用?C# System.Xml.XmlTextReader.ReadOuterXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了System.Xml.XmlTextReader.ReadOuterXml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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();
//.........这里部分代码省略.........
示例3: 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;
}