How do i read entries from an XML file, separate it in variables and assign them to a table?

Posted on 2006-04-20
Medium Priority
Last Modified: 2010-04-16
I want to get the  <name> and the <Point><coordinates> in a table ; lat, long and height.

<coordinates>-96.49996973904457,40.49996266664014,0</coordinates>  = lat,long,height

I want to use the dataset ReadXml to do this.


See below for XML file.

  <name>S3100 Master</name>
  <name>S3100 Slave</name>
Question by:mdalionheart
1 Comment

Accepted Solution

mmarksbury earned 2000 total points
ID: 16502652
I would use .NET's XML tools as shown below.

// Instantiate XmlDocument obj and load from file
XmlDocument XmlDoc = new XmlDocument();
XmlDoc.Load("path to file");

// Get All PlaceMark nodes
XmlNodeList Placemarks = XmlDoc.GetElementsByTagName("Placemark");

// Loop through Placemark Nodes
foreach(XmlNode N in Placemarks)
      String Name = N["name"].InnerText;
      String Coordinates = N["Point"]["coordinates"].InnerText;

      // Split by Comma
      Char[] SplitChar = {','};
      String[] SplitArray = Coordinates.Split(SplitChar);

      // Get Values as Decimal
      decimal Lat = Convert.ToDecimal(SplitArray[0]);
      decimal Long = Convert.ToDecimal(SplitArray[1]);
      decimal Height = Convert.ToDecimal(SplitArray[2]);

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question