如何从xml中的数据获取文本框 [英] How to get data from xml in to textbox

查看:64
本文介绍了如何从xml中的数据获取文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何从xml文档中的垂直元素文本中获取文本框

HOw can i get perticular element text from xml document in to text box

推荐答案

使用以下方法之一解析XML:

Use one of the following ways to parse XML:


  1. 使用System.Xml.XmlDocument类.它实现了DOM接口;如果文档太大,则这种方法最简单,也足够好.
    请参见
  2. 使用类System.Xml.XmlTextReader; library/system.xml.xmldocument.aspx"target =" _ blank"title =" New Window> ^ ].
  3. 使用类System.Xml.XmlTextReader;这是最快的读取方法,尤其是您需要跳过一些数据.
    请参见 http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx [ http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [http://msdn.microsoft.com/en-us/library/bb387063.aspx [

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].



您是否需要输入元素名称或值?无论如何,请使用属性TextBox.Text.

—SA



Do you need to put the element name or value? No matter, anyway, use the property TextBox.Text.

—SA


您可以使用XPath搜索来定位元素,如 ^ ].而不是将结果写入控制台(如示例中所示),而是将结果写入文本框.
You can locate an element using XPath search as shown here[^]. Instead of writing the result to Console (as shown in the example), write result to a text box.


这篇关于如何从xml中的数据获取文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆