• 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 /
This question was closed Jun 09, 2013 at 01:48 PM by Fattie for the following reason:

Question is off-topic or not relevant

avatar image
0
Question by jeffcrouse · Jun 09, 2013 at 01:20 AM · xmlparse

Parsing S3 directory listing

I am trying to use XmlDocument to parse an xml directory listing from an Amazon S3 bucket. There doesn't seem to be any Unity documentation, so I am using an example that I found in a C# Xml tutorial

 XmlDocument xmlDoc = new XmlDocument();
 xmlDoc.Load("http://rss.cnn.com/rss/edition_world.rss");
 XmlNode titleNode = xmlDoc.SelectSingleNode("//rss/channel/title");
 if(titleNode != null)
     Debug.Log(titleNode.InnerText); 

This works fine for that particular XML file, but when I put my stuff in there:

 XmlDocument xmlDoc = new XmlDocument();
 xmlDoc.Load("https://s3.amazonaws.com/themall/");
 Debug.Log ( xmlDoc.InnerXml );
 XmlNode nameNode = xmlDoc.SelectSingleNode("//Name");
 if(nameNode != null)
     Debug.Log(nameNode.InnerText); 

I get the raw XML in the console, so I know it is being downloaded successfully, but even the simplest XPath produces no results!

My only theory is that perhaps it has something to do with the default namespace in my XML? Do I need to tell XmlDocument about that somehow? Here is my root tag:

 <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">

I have tried creating an XmlNamespaceManager and using it with all of my calls to "SelectSingleNode", but that doesn't seem to work either.

 XPathNavigator nav = xmlDoc.CreateNavigator();
 XmlNamespaceManager ns = new XmlNamespaceManager(nav.NameTable);
 ns.AddNamespace(System.String.Empty, "http://s3.amazonaws.com/doc/2006-03-01/");

Finally, for the record, I have also tried using WWW to fetch the xml before parsing, but like I said, the above examples will print out the raw XML just fine, so I don't think that is the answer.

I can't believe I am encountering so much trouble with something as (relatively) simple as XML parsing, but I am hoping that someone can point me in the right direction.

Thanks!

Comment
Add comment
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

0 Replies

  • Sort: 

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

15 People are following this question.

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

Related Questions

int.parse() input string was not in correct format 0 Answers

WWW is not ready downloading yet? 1 Answer

Parsing large XML files on-the-fly, best practice? 1 Answer

Invalid Encoding Specification Xml 1 Answer

Parsing and displaying KML 0 Answers


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