且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从xml中的数据获取文本框

更新时间:2023-02-23 23:22:33

使用以下方法之一解析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. ].
  4. 使用类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.