using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Xml; namespace XML_Test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //Yahoo’mŒb‘Ü string XMLHTML = textBox1.Text; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(XMLHTML); XmlNamespaceManager NsManager = new XmlNamespaceManager(xmlDocument.NameTable); NsManager.AddNamespace("xsi", "urn:yahoo:jp:chiebukuro"); XmlNodeList nodeList = xmlDocument.SelectNodes("/xsi:ResultSet/xsi:Result/xsi:Question", NsManager); for (int i = 0; i < nodeList.Count; i++) { if (nodeList[i].HasChildNodes == true) { for (int j = 0; j < nodeList[i].ChildNodes.Count; j++) { if (nodeList[i].ChildNodes[j].LocalName == "Url") { textBox2.Text += "URL:" + nodeList[i].ChildNodes[j].InnerText + "\r\n"; } if (nodeList[i].ChildNodes[j].LocalName == "Content") { textBox2.Text += "Content:" + nodeList[i].ChildNodes[j].InnerText + "\r\n"; } } textBox2.Text += "\r\n"; } } } } }