本文整理匯總了C#中System.Xml.XmlTextReader.ReadInnerXml方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.ReadInnerXml方法的具體用法?C# XmlTextReader.ReadInnerXml怎麽用?C# XmlTextReader.ReadInnerXml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadInnerXml方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FromFile
public void FromFile(string filename, out string[] layerNameArray, out string[] collisionNameArray)
{
List<string> layerNames = new List<string>();
List<string> collisionNames = new List<string>();
XmlTextReader reader = new XmlTextReader(filename);
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == "CollisionLayer")
{
collisionNames.Add(reader.ReadInnerXml());
}
if (reader.Name == "TileLayer")
{
layerNames.Add(reader.ReadInnerXml());
}
}
}
reader.Close();
collisionNameArray = collisionNames.ToArray();
layerNameArray = layerNames.ToArray();
}
示例2: ReadDefects
void ReadDefects (string filename)
{
using (XmlTextReader reader = new XmlTextReader (filename)) {
Dictionary<string, string> full_names = new Dictionary<string, string> ();
// look for 'gendarme-output/rules/rule/'
while (reader.Read () && (reader.Name != "rule"));
do {
full_names.Add (reader ["Name"], "R: " + reader.ReadInnerXml ());
} while (reader.Read () && reader.HasAttributes);
// look for 'gendarme-output/results/
while (reader.Read () && (reader.Name != "results"));
HashSet<string> defects = null;
while (reader.Read ()) {
if (!reader.HasAttributes)
continue;
switch (reader.Name) {
case "rule":
defects = new HashSet<string> ();
ignore_list.Add (full_names [reader ["Name"]], defects);
break;
case "target":
string target = reader ["Name"];
if (target.IndexOf (' ') != -1)
defects.Add ("M: " + target);
else
defects.Add ("T: " + target);
break;
}
}
}
}
示例3: getStudentInfoByGet
//http request bt GET
//to get info of a student
public List<String> getStudentInfoByGet(string URL, string ID_No)
{
//Create the URL
List<String> infos = new List<string>();
String[] functions = { "GetStudentName", "GetStudentGender", "GetStudentMajor", "GetStudentEmailAddress" };
string function = "";
for (int i = 0; i < functions.Length; i++)
{
function = functions[i];
string strURL = URL + function + "?ID_No=" + ID_No;
//Initiate, DO NOT use constructor of HttwWebRequest
//DO use constructor of WebRequest
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
request.Method = "GET";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
Stream s = response.GetResponseStream();
XmlTextReader reader = new XmlTextReader(s);
reader.MoveToContent();
string xml = reader.ReadInnerXml();
////////
xml = xml.Split(new Char[] { '<', '>' })[2];
/////////
infos.Add(xml);
}
}
return infos;
}
示例4: CacheDocs
/// <summary>
/// Cache the xmld docs into a hashtable for faster access.
/// </summary>
/// <param name="reader">An XMLTextReader containg the docs the cache</param>
private void CacheDocs(XmlTextReader reader)
{
object oMember = reader.NameTable.Add("member");
reader.MoveToContent();
while (!reader.EOF)
{
if ((reader.NodeType == XmlNodeType.Element) && (reader.Name.Equals(oMember)))
{
string ID = reader.GetAttribute("name");
string doc = reader.ReadInnerXml().Trim();
doc = PreprocessDoc(ID, doc);
if (docs.ContainsKey(ID))
{
Trace.WriteLine("Warning: Multiple <member> tags found with id=\"" + ID + "\"");
}
else
{
docs.Add(ID, doc);
}
}
else
{
reader.Read();
}
}
}
示例5: InsertStudentInfoByPost
//http request bt POST
//to add new info of a student
public String InsertStudentInfoByPost(string URL, String Info)
{
string strURL = URL+ "InsertStudentInfo";
Encoding myEncoding = Encoding.GetEncoding("utf-8");
string param = "Info="+ HttpUtility.UrlEncode(Info, myEncoding);
byte[] bs = Encoding.ASCII.GetBytes(param);
string result="";
//Initiate, DO NOT use constructor of HttwWebRequest
//DO use constructor of WebRequest
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
//POST
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
request.ContentLength = bs.Length;
using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(bs, 0, bs.Length);
}
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
//DEAL with return values here
Stream s = response.GetResponseStream();
XmlTextReader reader = new XmlTextReader(s);
reader.MoveToContent();
result = reader.ReadInnerXml();
////////
result=result.Split(new Char[] { '<', '>' })[2];
/////////
}
return result;
}
示例6: InitLanguage
/// <summary>
/// 字符資源
/// </summary>
/// <param name="LanguageFileName">當前語言文件</param>
public void InitLanguage(String LanguageFileName)
{
String tag = String.Empty;
String text = String.Empty;
XmlTextReader reader = new XmlTextReader(LanguageFileName);
_stringDic.Clear();
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
// The node is an element.
if (reader.Name == "Language")
{
LanguageType = reader.GetAttribute("Type");
continue;
}
tag = reader.Name.Trim();
text = reader.ReadInnerXml().Trim();
if (!String.IsNullOrEmpty(tag) && !String.IsNullOrEmpty(text))
{
_stringDic.Add(tag, text);
}
break;
default:
break;
}
}
}
示例7: InitLanguage
/// <summary>
/// 字符資源
/// </summary>
/// <param name="currentLanguage">當前語言</param>
public void InitLanguage(Language currentLanguage)
{
string tag = string.Empty;
string text = string.Empty;
string fileName = string.Format("Language\\{0}.xml", currentLanguage.ToString());
XmlTextReader reader = new XmlTextReader(fileName);
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
if (reader.Name == "Language")
{
continue;
}
tag = reader.Name.Trim();
text = reader.ReadInnerXml().Trim();
if (!string.IsNullOrEmpty(tag) && !string.IsNullOrEmpty(text))
{
_stringDic.Add(tag, text);
//System.Diagnostics.Debug.WriteLine(tag + ",");
}
break;
}
}
}
示例8: SerializeAsXmlNode
public XmlNode SerializeAsXmlNode(XmlDocument doc)
{
System.IO.MemoryStream ms = new MemoryStream();
XmlSerializer serializer = new XmlSerializer(typeof(ColumnCollection));
XmlTextReader xRead = null;
XmlNode xTable = null;
try
{
xTable = doc.CreateNode(XmlNodeType.Element, "TABLE", doc.NamespaceURI);
serializer.Serialize(ms, this);
ms.Position = 0;
xRead = new XmlTextReader( ms );
xRead.MoveToContent();
string test = xRead.ReadInnerXml();
XmlDocumentFragment docFrag = doc.CreateDocumentFragment();
docFrag.InnerXml = test;
xTable.AppendChild(docFrag);
}
catch(Exception ex)
{
throw new Exception("IdentityCollection Serialization Error.", ex);
}
finally
{
ms.Close();
if (xRead != null) xRead.Close();
}
return xTable;
}
示例9: InitLanguage
/// <summary>
/// 字符資源
/// </summary>
/// <param name="languageFileName">當前語言文件</param>
public static void InitLanguage(string languageFileName)
{
var tag = string.Empty;
var text = string.Empty;
var reader = new XmlTextReader(languageFileName);
StringDic.Clear();
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
// The node is an element.
if (reader.Name == "Language")
{
LanguageType = reader.GetAttribute("Type");
continue;
}
tag = reader.Name.Trim().Replace("_","").ToUpper();
text = reader.ReadInnerXml().Trim();
if (!string.IsNullOrEmpty(tag) && !string.IsNullOrEmpty(text))
{
StringDic.Add(tag, text);
}
break;
default:
break;
}
}
}
示例10: GetLocationData
public static Location GetLocationData(string street,
string zip,
string city,
string state,
string country)
{
// Use an invariant culture for formatting numbers.
NumberFormatInfo numberFormat = new NumberFormatInfo();
Location loc = new Location();
XmlTextReader xmlReader = null;
try
{
HttpWebRequest webRequest = GetWebRequest(street, zip, city, state);
HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
using (xmlReader = new XmlTextReader(response.GetResponseStream()))
{
while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "Result")
{
XmlReader resultReader = xmlReader.ReadSubtree();
while (resultReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "Latitude")
loc.Latitude = Convert.ToDouble(xmlReader.ReadInnerXml(), numberFormat);
if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "Longitude")
{
loc.Longitude = Convert.ToDouble(xmlReader.ReadInnerXml(), numberFormat);
break;
}
}
}
}
}
}
finally
{
if (xmlReader != null)
xmlReader.Close();
}
// Return the location data.
return loc;
}
示例11: AsDataTable
public static DataTable AsDataTable(this string xmlString)
{
DataSet dataSet = new DataSet();
XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(xmlString));
reader.Read();
string inner = reader.ReadInnerXml();
dataSet.ReadXml(reader);
return dataSet.Tables[0];
}
示例12: DailyQueueConfiguration
public DailyQueueConfiguration()
{
cookies = new CookieCollection();
try
{
//grab the user and password values from the config file
using (XmlTextReader reader = new XmlTextReader(CONFIG_XML))
{
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
if (reader.Name == USER_NODE_NAME)
{
user = reader.ReadInnerXml();
}
else if (reader.Name == PASSWORD_NODE_NAME)
{
password = reader.ReadInnerXml();
}
break;
}
}
reader.Close();
}
}
catch (FileNotFoundException e)
{
string msg = e.Message;
//create the configuration file
using (XmlWriter writer = XmlWriter.Create(CONFIG_XML))
{
writer.WriteStartDocument();
writer.WriteStartElement("config");
writer.WriteElementString("user", "");
writer.WriteElementString("password", "");
writer.WriteEndElement();
writer.WriteEndDocument();
}
}
}
示例13: Read
/// <summary>
/// Read the specified xml and uri.
/// </summary>
/// <description>XML is the raw Note XML for each note in the system.</description>
/// <description>uri is in the format of //tomboy:NoteHash</description>
/// <param name='xml'>
/// Xml.
/// </param>
/// <param name='uri'>
/// URI.
/// </param>
public static Note Read(XmlTextReader xml, string uri)
{
Note note = new Note (uri);
DateTime date;
int num;
string version = String.Empty;
while (xml.Read ()) {
switch (xml.NodeType) {
case XmlNodeType.Element:
switch (xml.Name) {
case "note":
version = xml.GetAttribute ("version");
break;
case "title":
note.Title = xml.ReadString ();
break;
case "text":
// <text> is just a wrapper around <note-content>
// NOTE: Use .text here to avoid triggering a save.
note.Text = xml.ReadInnerXml ();
break;
case "last-change-date":
if (DateTime.TryParse (xml.ReadString (), out date))
note.ChangeDate = date;
else
note.ChangeDate = DateTime.Now;
break;
case "last-metadata-change-date":
if (DateTime.TryParse (xml.ReadString (), out date))
note.MetadataChangeDate = date;
else
note.MetadataChangeDate = DateTime.Now;
break;
case "create-date":
if (DateTime.TryParse (xml.ReadString (), out date))
note.CreateDate = date;
else
note.CreateDate = DateTime.Now;
break;
case "x":
if (int.TryParse (xml.ReadString (), out num))
note.X = num;
break;
case "y":
if (int.TryParse (xml.ReadString (), out num))
note.Y = num;
break;
}
break;
}
}
return note;
}
示例14: ddd
private void ddd(XYSaleBill sb)
{
try
{
string url = Common.AppSetting.httpurl;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
string postdata = "body=" + JsonConvert.SerializeObject(sb);
UTF8Encoding code = new UTF8Encoding(); //這裏采用UTF8編碼方式
byte[] data = code.GetBytes(postdata);
request.ContentLength = data.Length;
using (Stream stream = request.GetRequestStream()) //獲取數據流,該流是可寫入的
{
stream.Write(data, 0, data.Length); //發送數據流
stream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream ss = response.GetResponseStream();
XmlTextReader Reader = new XmlTextReader(ss);
Reader.MoveToContent();
string status = Reader.ReadInnerXml();
if (status == "302")
{
sb.UpDatePostInfo(1);
Common.AppLog.CreateAppLog().Info(string.Format("編號為:{0} 的單據於 {1} 更新成功", sb.sheet_id, DateTime.Now));
}
else
{
sb.UpDatePostInfo(0);
Common.AppLog.CreateAppLog().Error(string.Format("編號為:{0} 的單據於 {1} 更新失敗", sb.sheet_id, DateTime.Now));
}
}
}
catch (Exception ex)
{
Common.AppLog.CreateAppLog().Error(ex.Message);
}
}
示例15: ReadDocumentation
/// <summary>
/// Reads the documentation from the XML file provided via <paramref name="fileName"/>.
/// </summary>
/// <param name="fileName">Full path to the file containing the documentation.</param>
public Dictionary<string,string> ReadDocumentation(string fileName)
{
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreComments = true;
settings.IgnoreWhitespace = true;
settings.CloseInput = true;
if (!File.Exists(fileName))
{
/// The file either doesn't exist, or JustDecompile doesn't have permissions to read it.
return new Dictionary<string, string>();
}
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete))
{
Dictionary<string, string> documentationMap = new Dictionary<string, string>();
using (XmlTextReader reader = new XmlTextReader(fs, XmlNodeType.Element, null))
{
try
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == "member")
{
string elementName = reader.GetAttribute("name"); // The assembly member to which the following section is related.
string documentation = RemoveLeadingLineWhitespaces(reader.ReadInnerXml()); // The documenting section.
// Keep only the documentation from the last encountered documentation tag. (similar to VS Intellisense)
documentationMap[elementName] = documentation;
}
}
}
}
catch (XmlException e)
{
// the XML file containing the documentation is corrupt.
return new Dictionary<string,string>();
}
}
return documentationMap;
}
}