- Home /
Question is off-topic or not relevant
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!
Follow this Question
Related Questions
Invalid Encoding Specification Xml 1 Answer
Parsing and displaying KML 0 Answers
Is pulling and parsing XML data from 3rd party API call possible? 1 Answer
How can I store data from an XML in lists 0 Answers
Need Help Serializing/Deserializing XML 0 Answers