本文整理汇总了C#中XmlTextReader类的典型用法代码示例。如果您正苦于以下问题:C# XmlTextReader类的具体用法?C# XmlTextReader怎么用?C# XmlTextReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlTextReader类属于命名空间,在下文中一共展示了XmlTextReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ToDataSet
public static DataSet ToDataSet(DataSetData dsd)
{
DataSet ds = new DataSet();
UTF8Encoding encoding = new UTF8Encoding();
Byte[] byteArray = encoding.GetBytes(dsd.DataXML);
MemoryStream stream = new MemoryStream(byteArray);
XmlReader reader = new XmlTextReader(stream);
ds.ReadXml(reader);
XDocument xd = XDocument.Parse(dsd.DataXML);
foreach (DataTable dt in ds.Tables)
{
var rs = from row in xd.Descendants(dt.TableName)
select row;
int i = 0;
foreach (var r in rs)
{
DataRowState state = (DataRowState)Enum.Parse(typeof(DataRowState), r.Attribute("RowState").Value);
DataRow dr = dt.Rows[i];
dr.AcceptChanges();
if (state == DataRowState.Deleted)
dr.Delete();
else if (state == DataRowState.Added)
dr.SetAdded();
else if (state == DataRowState.Modified)
dr.SetModified();
i++;
}
}
return ds;
}
开发者ID:RandWilliams,项目名称:SWE7903,代码行数:31,代码来源:DataSetData.cs
示例2: process
public static void process(XamlOptions options, string input) {
if (!input.EndsWith(".xaml")) {
Console.WriteLine("Input filenames must end in .xaml");
return;
}
if (Environment.Version.Major < 2 && options.Partial) {
Console.WriteLine("This runtime version does not support partial classes");
return;
}
if (options.OutputFile == null) {
options.OutputFile = input + ".out";
}
ICodeGenerator generator = getGenerator(options.OutputLanguage);
XmlTextReader xr = new XmlTextReader(input);
try {
string result = ParserToCode.Parse(xr, generator, options.Partial);
TextWriter tw = new StreamWriter(options.OutputFile);
tw.Write(result);
tw.Close();
}
catch (Exception ex) {
Console.WriteLine("Line " + xr.LineNumber + ", Column " + xr.LinePosition);
throw ex;
}
}
开发者ID:alesliehughes,项目名称:olive,代码行数:25,代码来源:xamlc.cs
示例3: Main
static void Main(string[] args)
{
string localURL = @"http://ip-address.domaintools.com/myip.xml";
XmlTextReader xmlreader = null;
xmlreader = new XmlTextReader (localURL);
while (xmlreader.Read())
{
if(xmlreader.NodeType == XmlNodeType.Element)
{
Console.WriteLine("Element : " + xmlreader.Name);
}
if(xmlreader.NodeType == XmlNodeType.Text)
{
Console.WriteLine("Value : " +xmlreader.Value);
}
}
if (xmlreader != null)
xmlreader.Close();
}
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:25,代码来源:example1.cs
示例4: Mirror
public Mirror(string spec)
{
objectStack = new Stack();
objectStack.Push(null);
// Register the commands
commands = new List<Command>();
commands.Add(new ElementCommand());
commands.Add(new EndElementCommand());
commands.Add(new AttributeCommand());
Reader = new XmlTextReader(spec);
while (Reader.Read())
{
InterpretCommands();
var b = Reader.IsEmptyElement;
if (Reader.HasAttributes)
{
for (var i = 0; i < Reader.AttributeCount; i++)
{
Reader.MoveToAttribute(i);
InterpretCommands();
}
}
if (b) Pop();
}
}
开发者ID:david--liu,项目名称:code_kata,代码行数:28,代码来源:Mirror.cs
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string userName = "simonbegg";
string password = "techn0l0gy";
DataSet ds = new DataSet();
Twitter twitter = new Twitter();
XmlDocument xmlDoc = twitter.GetUserTimelineAsXML(userName, password, "simonbegg", Twitter.OutputFormatType.XML);
var query = (from c in xmlDoc.DocumentElement.ChildNodes.Cast<XmlNode>()
select c.SelectSingleNode("text").InnerXml).Take(2);
XmlTextReader xtr = new XmlTextReader(new StringReader(xmlDoc.OuterXml));
XElement xe = XElement.Load(xtr);
string tweets = String.Empty;
var foo = (from c in xe.Elements("status")
select c.Element("text")).First();
foreach (string tweet in query)
tweets += tweet + "<br />";
this.litTweet.Text = foo.ToString();
this.litTweetHeader.Text = "Latest tweets from talamh";
}
开发者ID:simonbegg,项目名称:LiveFreeRange,代码行数:29,代码来源:Twitter.ascx.cs
示例6: LevelDataXML
public void LevelDataXML(string pathToXml)
{
parseFile = Resources.Load(pathToXml) as TextAsset;
platforms = new List<PlatformData>();
metadata = new List<MetaData>();
portalSpawns = new List<Portal>();
hazardSpawns = new List<Hazard>();
playerSpawns = new List<Vector2>();
enemySpawns = new List<Vector2>();
items = new List<Vector2>();
XmlTextReader mapReader = new XmlTextReader(new StringReader(parseFile.text));
mapReader.Read();
XmlDocument doc = new XmlDocument();
doc.LoadXml(mapReader.ReadOuterXml());
mapSize = new Vector2((float)int.Parse(doc.ChildNodes[0].Attributes[0].Value)/16, (float)int.Parse(doc.ChildNodes[0].Attributes[1].Value)/16);
for (int x = 0; x < doc.ChildNodes[0].ChildNodes.Count; x++)
{
if (doc.ChildNodes[0].ChildNodes[x].Name.ToLower().Equals("frontlayer")) {
LoadTiles(doc.ChildNodes[0].ChildNodes[x], platforms);
}
if (doc.ChildNodes[0].ChildNodes[x].Name.ToLower().Equals("entities"))
{
LoadSpawnPoints(doc.ChildNodes[0].ChildNodes[x]);
}
}
}
开发者ID:riktothepast,项目名称:LD30,代码行数:26,代码来源:LevelData.cs
示例7: GetDialogById
public List<string> GetDialogById(string id)
{
XmlTextReader reader = new XmlTextReader(XMLFileName);
List<string> texts = new List<string>();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == id)
{
int i = 0;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.EndElement && reader.Name == id)
{
break;
}
if (reader.NodeType == XmlNodeType.Element && reader.Name == ("text_" + i))
{
texts.Add(reader.ReadElementContentAsString());
i++;
}
}
}
}
reader.Close();
return texts;
}
开发者ID:AlexanderMekumyanov,项目名称:SerKnight,代码行数:28,代码来源:DialogSystem.cs
示例8: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) //sürekli japon yeni ni ekliyodu butonda bu yüzden bunu ekledik sadece ilk postback olduğunda yapar sonraki postbackları yapmaz
{
ListItem aa;
//ddlKurlar.Items.Add(new ListItem("japon yeni", "2,2")); 7/merkez bankasından xml alıcaz
XmlTextReader re = new XmlTextReader("http://www.tcmb.gov.tr/kurlar/today.xml");
string txt = "";
string value = "";
while (re.Read()) {
if(re.NodeType==XmlNodeType.Element)
if (re.Name == "Isim") {
txt = re.ReadString();
}
if (re.Name == "CrossRateUSD")
{
value = re.ReadString();
if (value == "")
continue; //boş değerleri böylece götürdük ddl deki
aa = new ListItem();
aa.Text = txt;
aa.Value = value.Replace(".", ",");
ddlKurlar.Items.Add(aa);
}
}
}
}
开发者ID:madmed,项目名称:netron,代码行数:32,代码来源:Default.aspx.cs
示例9: SetAppTypeProduct
public void SetAppTypeProduct()
{
try
{
XmlDocument doc = new XmlDocument();
string xpath = Server.MapPath("../data/xml/configproduct.xml");
XmlTextReader reader = new XmlTextReader(xpath);
doc.Load(reader);
reader.Close();
XmlNodeList nodes = doc.SelectNodes("/root/product");
int numnodes = nodes.Count;
for (int i = 0; i < numnodes; i++)
{
string nameapp = nodes.Item(i).ChildNodes[0].InnerText;
string idtype = nodes.Item(i).ChildNodes[1].InnerText;
string appunit = nodes.Item(i).ChildNodes[2].InnerText;
string unit = nodes.Item(i).ChildNodes[3].InnerText;
if (nameapp.Length > 0 && idtype.Length > 0)
{
Application[nameapp] = int.Parse(idtype);
}
if (appunit.Length > 0 && unit.Length > 0)
{
Application[appunit] = unit;
}
}
}
catch
{
}
}
开发者ID:BGCX261,项目名称:zlap-svn-to-git,代码行数:32,代码来源:AdminWebsite.aspx.cs
示例10: ReadOrthographicSize
void ReadOrthographicSize(XmlTextReader textReader, GameObject go)
{
ScanToNode(textReader, "OrthographicSize");
float size = GetFloat(textReader);
Camera camera = go.GetComponent(typeof(Camera)) as Camera;
camera.orthographicSize = size;
}
开发者ID:CodeStrumpet,项目名称:Elemental,代码行数:7,代码来源:LoadXmlSettings.cs
示例11: Read
public static void Read()
{
XmlTextReader reader = new XmlTextReader("books.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
Console.Write("<" + reader.Name);
while (reader.MoveToNextAttribute()) // Read the attributes.
Console.Write(" " + reader.Name + "='" + reader.Value + "'");
Console.WriteLine(">");
break;
case XmlNodeType.Text: //Display the text in each element.
Console.WriteLine (reader.Value);
break;
case XmlNodeType. EndElement: //Display the end of the element.
Console.Write("</" + reader.Name);
Console.WriteLine(">");
break;
}
}
// Do some work here on the data.
Console.ReadLine();
}
开发者ID:walrus7521,项目名称:code,代码行数:25,代码来源:Xml.cs
示例12: GetItemsList
public string[] GetItemsList(string prefixText, int count)
{
List<string> suggestions = new List<string>();
using (XmlTextReader reader = new XmlTextReader(HttpContext.Current.Server.MapPath("flightdata.xml")))
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "departurelocation")
{
string itemName = reader.ReadInnerXml();
if (itemName.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase))
{
if (!suggestions.Contains(itemName))
suggestions.Add(itemName);
if (suggestions.Count == count) break;
}
}
if (reader.NodeType == XmlNodeType.Element && reader.Name == "destinationlocation")
{
string itemName = reader.ReadInnerXml();
if (itemName.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase))
{
if (!suggestions.Contains(itemName))
suggestions.Add(itemName);
if (suggestions.Count == count) break;
}
}
}
}
return suggestions.ToArray();
}
开发者ID:marvinrusinek,项目名称:Skyscanner,代码行数:35,代码来源:Autocomplete.cs
示例13: RunNotWellFormedTest
static void RunNotWellFormedTest (string subdir, bool isSunTest)
{
string basePath = @"xml-test-suite/xmlconf/" + subdir + @"/not-wf";
DirectoryInfo [] dirs = null;
if (isSunTest)
dirs = new DirectoryInfo [] {new DirectoryInfo (basePath)};
else
dirs = new DirectoryInfo (basePath).GetDirectories ();
foreach (DirectoryInfo di in dirs) {
foreach (FileInfo fi in di.GetFiles ("*.xml")) {
try {
XmlTextReader xtr = new XmlTextReader (fi.FullName);
xtr.Namespaces = false;
while (!xtr.EOF)
xtr.Read ();
Console.WriteLine ("Incorrectly wf: " + subdir + "/" + di.Name + "/" + fi.Name);
} catch (XmlException) {
// expected
} catch (Exception ex) {
Console.WriteLine ("Unexpected Error: " + subdir + "/" + di.Name + "/" + fi.Name + "\n" + ex.Message);
}
}
}
}
开发者ID:nobled,项目名称:mono,代码行数:25,代码来源:xmltest.cs
示例14: readXML
private void readXML()
{
string fileName = "/home/nasser/Desktop/ncg/ncg/sampledata.xml";
if (File.Exists (fileName)) {
XmlTextReader xreader = new XmlTextReader(fileName);
label1.Text="";
while(xreader.Read ())
{
if(xreader.NodeType==XmlNodeType.Element)
{
xreader.Read();
if(xreader.NodeType==XmlNodeType.Text)
{
}
}
/*label1.Text+="\nnode type :\t"+xreader.NodeType.ToString ();
label1.Text+="\nname : \t\t"+xreader.Name;
label1.Text+="\nvalue :\t\t"+xreader.Value;
label1.Text+="\n-----------------";*/
}
//label1.Text+="\n"+xreader.GetAttribute("version").ToString ();
}
else
label1.Text="file not exists";
}
开发者ID:nasserman,项目名称:ngc,代码行数:27,代码来源:MainWindow.cs
示例15: Button1_ServerClick
protected void Button1_ServerClick(object sender, EventArgs e)
{
try
{
string currency = idChoice.Value;
XmlDocument doc = new XmlDocument();
string url = Server.MapPath("../data/xml/configproduct.xml");
XmlTextReader reader = new XmlTextReader(url);
doc.Load(reader);
reader.Close();
if (doc.IsReadOnly)
{
diverr.Visible = true;
diverr.InnerHtml = "File XML đã bị khóa. Không thể thay đổi";
return;
}
XmlNode nodeEdit = doc.SelectSingleNode("root/product[nameappunit='currency']/unit");
string value = nodeEdit.InnerText;
if (!value.Equals(currency))
{
nodeEdit.InnerText = currency;
doc.Save(url);
Application["currency"] = currency;
diverr.Visible = true;
diverr.InnerHtml = "Đã thay đổi cách hiển thị tiền tệ";
}
else
{
diverr.Visible = true;
diverr.InnerHtml = "Hệ thống đang hiển thị kiểu tiền này.";
}
}catch
{}
}
开发者ID:BGCX261,项目名称:zlap-svn-to-git,代码行数:34,代码来源:ChangeCurrency.ascx.cs
示例16: GetAlbumArt
protected void GetAlbumArt(string albumId, string album, string artist)
{
string path = Server.MapPath(@"~/images/cover-art/");
if(!File.Exists(path + albumId + ".png")){
string url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=b25b959554ed76058ac220b7b2e0a026&artist=" + artist + "&album=" + album;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
XmlTextReader reader = new XmlTextReader(response.GetResponseStream());
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "image")
{
if (reader.GetAttribute("size").Equals("large"))
{
url = reader.ReadInnerXml();
WebClient webClient = new WebClient();
webClient.DownloadFile(url, path + albumId + ".png");
}
}
}
}
catch (Exception e)
{
}
}
}
开发者ID:dantomosoiu,项目名称:MusicMachine,代码行数:32,代码来源:UploadSong.aspx.cs
示例17: ReadXML
void ReadXML()
{
int typesCount = (int)MessageType.Count;
messages = new List<string>[typesCount];
for(int i = 0; i < typesCount; i++) {
messages[i] = new List<string>();
}
XmlTextReader reader = new XmlTextReader (file.text, XmlNodeType.Element, null);
while(reader.Read()) {
string typeName = reader.Name;
if(string.IsNullOrEmpty(typeName)) {
continue;
}
string message = reader.ReadString();
int mTypeIndex = (int)((MessageType)System.Enum.Parse(typeof(MessageType), typeName));
if(mTypeIndex >= 0 && mTypeIndex < typesCount) {
messages[mTypeIndex].Add(message);
// Debug.Log("Adding message: " + message + " for type " + typeName);
} else {
Debug.LogError("Unknown type " + typeName);
}
}
}
开发者ID:PavelDrabek,项目名称:GoldDigger,代码行数:26,代码来源:MessageGenerator.cs
示例18: GetItems
public List<MenuItem> GetItems()
{
XmlSerializer xs=new XmlSerializer(typeof(INVIMenu));
XmlTextReader xtr=new XmlTextReader(HttpContext.Current.Server.MapPath("../Web.sitemap"));
INVIMenu oMenu = xs.Deserialize(xtr) as INVIMenu;
return oMenu.siteMapNode.Items;
}
开发者ID:vantrung87hvt,项目名称:vietgap-thuysan,代码行数:7,代码来源:INVIMenu.cs
示例19: Main
static void Main (string[] args)
{
if (args.Length < 2)
{
Console.WriteLine("Syntax; VALIDATE xmldoc schemadoc");
return;
}
XmlValidatingReader reader = null;
try
{
XmlTextReader nvr = new XmlTextReader (args[0]);
nvr.WhitespaceHandling = WhitespaceHandling.None;
reader = new XmlValidatingReader (nvr);
reader.Schemas.Add (GetTargetNamespace (args[1]), args[1]);
reader.ValidationEventHandler += new ValidationEventHandler(OnValidationError);
while (reader.Read ());
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
if (reader != null)
reader.Close();
}
}
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:27,代码来源:Program.cs
示例20: GetTargetNamespace
public static string GetTargetNamespace (string src)
{
XmlTextReader reader = null;
try
{
reader = new XmlTextReader (src);
reader.WhitespaceHandling = WhitespaceHandling.None;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element &&
reader.LocalName == "schema")
{
while (reader.MoveToNextAttribute ())
{
if (reader.Name == "targetNamespace")
return reader.Value;
}
}
}
return "";
}
finally
{
if (reader != null)
reader.Close ();
}
}
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:27,代码来源:Program.cs
注:本文中的XmlTextReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论