2 Replies - 1427 Views - Last Post: 11 February 2013 - 07:37 AM Rate Topic: -----

#1 oyyou   User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 196
  • Joined: 26-April 10

Read Line XML File

Posted 09 February 2013 - 05:47 PM

So I'm creating a Windows Phone game in XNA (Just messing atm, seeing how I find it) and I've run into a problem.
First of all, it turns out you can user StreamReader to read text files (Insane).
Which lead me to using XML, of which I have 0 experience, so I'm kinda stumped.

I want to be able to go through and read the lines in the file, depending on the character it reads in each position, will depend on what is drawn on the screen (Just a simple tile map using 2D string array)

Here is my XML (In case you're interested)
<?xml version="1.0" encoding="utf-8" ?>
  <Asset Type="System.String">

Soo yeah, suggestions on reading it line-by-line?

Thank you (:

Is This A Good Question/Topic? 0
  • +

Replies To: Read Line XML File

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5207
  • View blog
  • Posts: 13,955
  • Joined: 18-April 07

Re: Read Line XML File

Posted 09 February 2013 - 06:06 PM

Perhaps the XmlTextReader class is what you are looking at using. Typically you don't go read a XML file like your standard text file... line by line. Instead you read in the text and then read the elements. Here you would be looking for the data element and retrieving its content. The XmlTextReader can use the read() method to read the content and from there you can determine how you want to handle each element.

When you find the data element, you can pass its contents on to any other function to render your tiled map.

Was This Post Helpful? 0
  • +
  • -

#3 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1533
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: Read Line XML File

Posted 11 February 2013 - 07:37 AM

You could also use the XDocument class which is great for reading XML documents to use with LINQ-To-XML.

I agree with Martyr2 that you don't normally read an XML file the same way as a standard text file.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1