■57477 / ) |
Re[9]: InnerTextによるXMLノードの取得 |
□投稿者/ 上条 (5回)-(2011/03/01(Tue) 05:34:24)
|
□投稿者/ shu さんへ
前回のヒントで改行コードを含んだテキストをノード間より取得できるようになりました。
ありがとうございます。
ただ問題としてchatの属性値であるnoの値が取得出来なくなりました。
現状を維持したままchatの属性値であるnoの値を取得できませんでしょうか。
質問ばかりで申し訳ありません。
----------------------成功コード
string come2 = "";
var xdoc1 = new XmlDocument();
xdoc1.LoadXml(String.Format("<root>{0}</root>", xml));
foreach (XmlNode ndtmp in xdoc1.ChildNodes)
{
foreach (XmlNode nd in ndtmp.ChildNodes)
{
var attr = nd.Attributes;
if (nd.Name == "chat")
{
come2 = String.Format(nd.InnerText);
this.Invoke(new MethodInvoker(delegate
{
this.dataGridView1.Rows.Add(comecount, come2);
}));
}
}
}
--------------------------noの値は表示されるがテキストが全て同じになるコード
string comecount = "";
XmlNodeList node = root.GetElementsByTagName("chat");
XmlElement xmlname = (XmlElement)node.Item(0);
comecount = xmlname.GetAttribute("no");
string come2 = "";
var xdoc1 = new XmlDocument();
xdoc1.LoadXml(String.Format("<root>{0}</root>", xml));
foreach (XmlNode ndtmp in xdoc1.ChildNodes)
{
foreach (XmlNode nd in ndtmp.ChildNodes)
{
var attr = nd.Attributes;
MessageBox.Show(nd.InnerText);
if (nd.Name == "chat")
{
come2 = String.Format(nd.InnerText);
this.Invoke(new MethodInvoker(delegate
{
this.dataGridView1.Rows.Add(comecount, come2);
}));
}
}
}
--------------------------------------------
□投稿者/ らら さんへ
はい、確かにニコニコ生放送関係です。
>xmlとして完結指定ない部分が含まれてないですか?
つまり完成したXMLを読み込んでいるわけではないということでしょうか?
|
|