Using data from InnerText

82 views Asked by At

Is there any option of using data - extracted from InnerText - as the pixels 'y' coordinates position?

I managed to get string elements from .xml file - tag "SequenceInfo".

Example of .xml file:

<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>

I get the text content of the specified node as follows:

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

Such data are being stored in object 'xtr' (InnerText property).

Can we push this data even further? For example as 'y' coordinates?

Part of my code below:

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");
2

There are 2 answers

3
Idle_Mind On

It's unclear if you've actually retrieved the data, and what you want to do with it once you've extracted it...but here's an example that should get you started:

        // ... 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());
        }
0
Kalolalo On

Problem solved. Here's my code:

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])});
            }