使用来自 InnerText 的数据



是否有任何选择使用从InnerText中提取的数据作为像素"y"坐标位置?

我设法从.xml文件中获取字符串元素 - 标签"序列信息"。

.xml文件示例:

<SequenceInfo HasSmoke="" Azimuth="267.2" Inclination="682" Zoom="10329" TowerName="Makoszka" Time="2015-03-18 13:10:22">
<Horizon>316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,320,320,320,321,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,324,324,324,324,324,324,324,326,326,326,326,326,326,326,326,324,324,322,322,322,322,322,322,322,322,322,322,322,322,323,324,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,324,324,322,322,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320</Horizon>
</SequenceInfo>

我得到指定节点的文本内容如下:

316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318, 318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,320,320,320,320,320,321,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,32

,324,326,326,326,326,326,326,326,326,326,324,324,322,322,322,322,322,322,322,322,322,322,322,322,323,324,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,324,324,322,322,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,32此类数据存储在对象"xtr"(InnerText 属性)中。

我们能进一步推动这些数据吗?例如作为"y"坐标?

我的部分代码如下:

XmlDocument xtr = new XmlDocument();
string fileName = OFD.FileName;
FileInfo fileInfo = new FileInfo(fileName);
string directoryFullPath = fileInfo.DirectoryName;
fileName = Path.Combine(directoryFullPath, "info.xml");
xtr.Load(fileName);
XmlNodeList list = xtr.GetElementsByTagName("SequenceInfo");

目前还不清楚你是否真的检索到了数据,以及一旦你提取了它,你想用它做什么......但这里有一个应该让你入门的例子:

// ... get the data from your XML somehow ...
string data = "316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,316,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,320,320,320,321,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,324,324,324,324,324,324,324,326,326,326,326,326,326,326,326,324,324,322,322,322,322,322,322,322,322,322,322,322,322,323,324,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,324,324,322,322,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320";
// Convert the Text Data to Points:
var points = from y in data.Split(",".ToCharArray()) select new Point(0, int.Parse(y));
// Do something with the Points:
foreach(Point p in points)
{
Console.WriteLine(p.ToString());
}

问题解决了。 这是我的代码:

XmlDocument xtr = new XmlDocument();
string fileName = OFD.FileName;
FileInfo fileInfo = new FileInfo(fileName);
string directoryFullPath = fileInfo.DirectoryName;
fileName = Path.Combine(directoryFullPath, "info.xml");
xtr.Load(fileName);
XmlNodeList list = xtr.GetElementsByTagName("SequenceInfo");
string[] punkty = xtr.InnerText.Split(',');
List<Point> punkty1 = new List<Point>();
for (int i = 0; i < punkty.Length; i++)
{
punkty1.Add(new Point { X = i, Y = int.Parse(punkty[i])});
}

相关内容

  • 没有找到相关文章

最新更新