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

#1 oyyou  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 184
  • 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" ?>
<XnaContent>
  <Asset Type="System.String">
    <data>
      000000
      1----1
    </data>
  </Asset>
</XnaContent>



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  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4354
  • View blog
  • Posts: 12,160
  • 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  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • 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