Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8474041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:31:04+00:00 2026-06-10T17:31:04+00:00

I want to read XML like this. <?xml version=1.0 encoding=utf-8 ?> <parent> <path> <pathPoints>

  • 0

I want to read XML like this.

<?xml version="1.0" encoding="utf-8" ?>
<parent>
  <path>
    <pathPoints>
     <point>
        2 0
      </point>
      <point>
        2 1
      </point>
        3 1
      <point>
        3 2
      </point>
      <point>
        4 2
      </point>
      <point>
        4 4
      </point>
      <point>
        3 4
      </point>
      <point>
        3 5
      </point>
      <point>
      2 5
      </point>
      <point>
        2 7
      </point>
      <point>
          7 7
      </point>
      <point>
          7 5
      </point>
      <point>
        10 5
      </point>
      <point>
        10 2
      <point>
      </point>
      15 2
      </point>
      <point>
        15 6
      </point>
      <point>
        16 6
      </point>
      <point>
        16 7
      </point>
      <point>
        17 7
      </point>
      <point>
        17 10
      </point>
      <point>
        19 10
      </point>
    </pathPoints>
  </parent>
</path>

And now I’m trying to read it:

        paths = (from path in doc.Descendants("path")
                 select new AIPath()
                 {
                     waypoints = (from i in path.Descendants("pathPoints")
                     {
                         int j = Convert.ToInt32(i.Element("point").Value),
                     }).ToList();
                 }
                 ).ToList();

My AIPath contains a list of vector2 called waypoints.

What I want to know is what I’m doing wrong. I want to create a new path everytime it changes which path it’s looking at, which looks fine. What I’m confused about though is waht to do next. After the waypoints = (from i in path.Descendants(“pathPoints”), I’m expecting i have to do something but I’m clueless as to what.

Any help would be greatly appreciated.

Edit

One or two details I forgot to add.

public class AIPath
{
    //public Vector2
    public List<Vector2> waypoints { get; set; }
    public int linkNumber { get; set; }
    public int[] potentialLinks { get; set; }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:31:06+00:00Added an answer on June 10, 2026 at 5:31 pm

    Currently, your XML output is relatively hard to parse. I would rewrite your code like this:

    public sealed class AIPath
    {
        // TODO: Consider trying to make this immutable, or
        // at least not exposing the collections so widely. Exposing an array
        // property is almost always a bad idea.
        public List<Vector2> Waypoints { get; set; }
        public int LinkNumber { get; set; }
        public int[] PotentialLinks { get; set; }
    
        public XElement ToElement()
        {
            return new XElement("path",
                WayPoints.Select(v2 => new XElement("point",
                                           new XAttribute("X", (int) v2.X),
                                           new XAttribute("Y", (int) v2.Y))));
        }
    
        public static AIPath FromXElement(XElement path)
        {
            return new AIPath
            {
                WayPoints = path.Elements("point")
                                .Select(p => new Vector2((int) p.Attribute("X"),
                                                         (int) p.Attribute("Y")))
                                .ToList();
            };
        }
    }
    

    Then:

    paths = doc.Descendants("path")
               .Select(x => AIPath.FromXElement(x))
               .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XML document that looks something like this: <?xml version=1.0 encoding=UTF-8?> <citizen>
I have XML which looks something like this: <?xml version=1.0 encoding=utf-8?> <University> <Colleges> <College>
Hi I can't understand this error I want read this XML file: <?xml version=1.0
I have the following XML file: <xml version=1.0 encoding=utf-8?> <Data> <Parameter1>1</Parameter1> </Data> I want
I want have the following output: <?xml version=1.0 encoding=UTF-8?> <structure:structuralDataRoot xmlns:register=http://www.test.ch/register/1 xmlns:structure=http://test.ch/structure/1 > <structure:tester>ZH</structure:tester>
I want to read an xml file placed in assets/ directory. I've tried this
I have the following code in resultlookup.xml <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:id=@+id/layoutResultOuter
I have the following xml structure : <?xml version=1.0 encoding=utf-8 ?> <nws> <url>http://cpa.hypotheses.org/feed</url> <url>http://news.ycombinator.com/rss</url>
I am trying to read this XML file using PHP and I have two
I want to read an .xml file from a web radio for my app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.