XML with elements like foo:bar

philprice

Well-known member
Joined
Mar 21, 2003
Messages
116
Location
Hull, UK
basically i have some xml..

Code:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
xmlns:dc="http://purl.org/dc/elements/1.1/" 
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns="http://purl.org/rss/1.0/">
- <channel rdf:about="http://sablog.com/">

as you see the first node is called rdf:RDF, but if i ask the XPathNodeIterator to look down /rdf:RDF/channel/item it does not like it, so what do i ask it to look down. I do it like this

Code:
 XMLStoryItems = docNavigator.Select(feed.feedType.newsNodePath)

 feed.feedType.newsNodePath is = to "/rdf:RDF/channel/item"
 
you will need to use a namespacemanager:

C#:
XPathExpression Expr = docNavigator.Compile("/rdf:RDF/channel/item");
XmlNamespaceManager context = new XmlNameSpaceManager(docNavigator.NameTable);
context.AddNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
Expr.SetContext(context);
XPathNodeIterator Iterator = docNavigator.Select(Expr);

phew... I hope I got everything.. couldnt test it, but it should give you the general idea :)
 
Last edited by a moderator:
Hmm it doesnt seem to work the path is /rdf:RDF/item anyway but i fixed that, does like allow to be traverse the sub list anyway? Ie i want to do XMLNewsStories.MoveNext() and look through.

My code for this

Code:
 Loop through story items and parse
        Do While (XMLStoryItems.MoveNext)
            Dim newStory As New RSSStory
            newStory = Process_Node(XMLStoryItems.Current)
            If (Not newStory Is Nothing) Then
                If (feed.feedType.supportsDescription = True And newStory.description <> "") Then
                    newStory.hasDescription = True
                End If
                colStories.Add(newStory)
            End If
        Loop

It seems to select stuff into current or something, im not sure - whatever it doesnt really work..
 
Back
Top