Skip to content

Instantly share code, notes, and snippets.

@scottsappen
Created July 1, 2013 15:26
Show Gist options
  • Save scottsappen/5901820 to your computer and use it in GitHub Desktop.
Save scottsappen/5901820 to your computer and use it in GitHub Desktop.
ASP.Net XMLDocument to incorporate a blog roll
Let’s say you have a WordPress blog at another domain and you want to show it on another domain.
Well, you’re better off using a more standard way of incorporating a WordPress blog into your website (just google around), but if you need to do something more custom, here’s a possibility.
Here’s some pseudo code for a .Net application – you get the idea. One thing to keep in mind is that XMLDocument is not serializable, so if you want to save it in a session state or do something else, you will need to work around it.
Dim xmlReader As XmlReader = xmlReader.Create("your website blog url goes here/feed/rss")
Dim xmlDocument As XmlDocument = New XmlDocument
xmlDocument.Load(xmlReader)
Dim xmlNameSpaceManager As XmlNamespaceManager = New XmlNamespaceManager(xmlDocument.NameTable)
xmlNameSpaceManager.AddNamespace("content", "http://purl.org/rss/1.0/modules/content/")
xmlNameSpaceManager.AddNamespace("wfw", "http://wellformedweb.org/CommentAPI/")
xmlNameSpaceManager.AddNamespace("dc", "http://purl.org/dc/elements/1.1/")
xmlNameSpaceManager.AddNamespace("atom", "http://www.w3.org/2005/Atom")
xmlNameSpaceManager.AddNamespace("sy", "http://purl.org/rss/1.0/modules/syndication/")
xmlNameSpaceManager.AddNamespace("slash", "http://purl.org/rss/1.0/modules/slash/")
Dim items As XmlNodeList = xmlDocument.SelectNodes("/rss/channel/item")
For Each item As XmlNode In items
Dim bloglink As String = item("link").InnerText
Dim blogTitle As String = item("title").InnerText
Dim pubDate As String = item("pubDate").InnerText
Dim blogAuthor As String = item("dc:creator").InnerText
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment