Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by hesa2020 · Jun 24, 2012 at 04:43 AM · listxmlreadshowto

Read STRING AS XML TO SHOW LIST

Hi, what i do is read a web page as string And read the string as xml Now i want to do a

 foreach (server in servers){
  servername = server.servername.value;
 }

Here the code i used to read string and convert it as xml :

 WWW PlayerInfoUrl = new WWW("http://poker.hesahost.com/fb_helpers/get_servers_virtual.php");
 yield return PlayerInfoUrl;
 XmlReader xmlReader = new XmlTextReader(new StringReader(PlayerInfoUrl.text));

Thanks for your help ! :P

EDIT : I want to make a datagrid too, like show colloms like : servername, server id and show row with the value , and the player can click on colloms cell to order by ...

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hesa2020 · Jun 24, 2012 at 03:08 PM 0
Share

Still need to find how to

avatar image Bunny83 · Jun 25, 2012 at 11:08 AM 0
Share

The X$$anonymous$$LTextReader class is a parser of type: pull parsing while XmlDocument parses the xml as DO$$anonymous$$.

Both are standard .NET classes. There are hundreds of examples out there. It also as been asked around 10 times here how to parse xml.

Furthermore parsing an xml string isn't really Unity specific.

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by flamy · Jun 24, 2012 at 08:17 PM

First of all really good question.

And you where trying to use , xmlTextReader, which is a stream based class, what actually you should be doing is use a class that accepts a text input as xml not a file, XmlDocument is what i know.There might be other classes also, im not sure.

the below is the sample code i have check and can assure tht it works

  WWW PlayerInfoUrl;
  XmlDocument _doc;
 bool lol=false;
 
 // Use this for initialization
 void Start () {
     
     PlayerInfoUrl = new WWW("http://poker.hesahost.com/fb_helpers/get_servers_virtual.php");
     
 }
 
 // Update is called once per frame
 void Update () {
 
     
     if(PlayerInfoUrl.isDone && !lol)
     {
         _doc= new XmlDocument();
         _doc.LoadXml(PlayerInfoUrl.text);
         print (PlayerInfoUrl.text);
         lol=true;
     }
     
 }

PS: XmlDocument class works on android and iphone also...

More info: to display it like a list of servers, first you have to decode the xml and get a string list for that look into xmlNodeList the snippet for fetching is

 XmlNodeList _list = _doc.SelectNodes("servers/server");

after fetching and saving it in a global variable display it from on gui. I hope this is clear??!

         foreach(XmlNode _node in _list)
         {
             if(GUILayout.Button(_node.Attributes.GetNamedItem("myAttribute").Value))
             {
                 //join the server
             }
         }



Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Jun 25, 2012 at 11:15 AM 1
Share

You might also want to take a look at the Lightweight X$$anonymous$$L parser since if you use the System.X$$anonymous$$L namespace it will increase your build size by around 1 $$anonymous$$B.

avatar image flamy · Jun 25, 2012 at 12:01 PM 0
Share

oh! looks intresting, ill take a look into it. Thanks

avatar image koslovdenis · Mar 08, 2019 at 06:21 PM 0
Share

Hello, I am from 2019 and XmlDocument doesn't work on Android... I am wondering how do you declare a path within a jar file in Android? I used tons of options and none worked. I start to feel crazy. This is what i used the last time:

 xml_path = "jar:file//" + Application.dataPath + "!/" + "file.xml";

Please help, if you know. Thanks!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

using xml, linq, and lists 0 Answers

New to XML in C#, can't get anything to work. 1 Answer

Xml Serialization? (how to read/write?) 1 Answer

Write and Read to a iOS device! Help 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges