This isn’t directly just with Amazon, but it is a problem we ran into when working with a VB application using Amazon’s Route 53 DNS Service.
Our application uses DataTables to create drop down menus, list values, etc… Amazon’s result sets are in XML. So, the best way to dig through an XML file is to use XPath queries. It’s pretty easy… unless Microsoft makes a decision to ruin your day with a “bug” who’s “Behavior is by Design”.
Basically, if you leave the default namespace on the leading line of the XML doc, XPath queries don’t work. They don’t error, they just don’t return anything.
http://support.microsoft.com/default.aspx?scid=kb;en-us;313372
Dim contents As String = reader.ReadToEnd()
'contents = contents.Replace("<!--?xml version=""1.0""?-->", "")
contents = System.Text.RegularExpressions.Regex.Replace(contents, "(^\s+)|(\s+$)|(\s+(?=\s.))", "")
contents = contents.Replace("> contents = contents.Replace(vbLf, "")
contents = contents.Replace("xmlns=""https://route53.amazonaws.com/doc/2010-10-01/""", "")
So, I got rid of the white spaces. I got rid of the line feeds and I removed their xmlns.
Suddenly, I could do this:
Dim xmlDoc As New Xml.XmlDocument
xmlDoc.LoadXml(contents)
Dim nodeList As Xml.XmlNodeList
' xmlDoc.SelectNodes("ListResourceRecordSetsResponse/ResourceRecordSets/ResourceRecordSet").Count
Dim pattern As String = "ListResourceRecordSetsResponse/ResourceRecordSets/ResourceRecordSet"
nodeList = xmlDoc.SelectNodes(pattern)
And get a nice set of records. From there it was just a lot of grunt work to get it moving, but no more spending all day long trying to get past that idiotic empty recordset.
Thanks Microsoft.

No comments yet
No comments yet.
RSS feed for comments on this post. TrackBack URL
Leave a comment