libxml and serialization
BlitzMax Forums/Brucey's Modules/libxml and serialization
| ||
| Is there an example for reading xml files that use serialization? I'm going to read rss feeds, if anyone has experience doing that I'm looking for an example on that too. |
| ||
| example of rss 2.0 feed taken from www.hulu.com/feed/show/60/episodes what is "<![CDATA[]]>"? |
| ||
| A CDATA section is Character Data that is not parsed in the same way as the rest of the document. It means, characters that are normally not allowed in XML (like < and > for example) can appear in the CDATA section. |
| ||
| Assuming RSS feeds use the same structure, I'd start by creating an object that matches that structure. Then write a little parser which maps the xml onto your object. say you have a String containing the feed : Local doc:TxmlDoc = TxmlDoc.parseDoc(text) Local root:TxmlNode = doc.GetRootElement() you might then pass the root node into a method of your mapper...
Method map:RSSObject(root:TxmlNode)
Local channel:TxmlNode = TxmlNode(root.GetFirstChild())
Local rss:RSSObject = new RSSObject
For Local part:TxmlNode = eachin channel.getChildren()
select part.GetName()
case "title"
rss.SetTitle(part.GetContent())
case "item"
mapItem(rss, part)
end select
Next
return rss
End Method
Method mapItem(rss:RSSObject, parent:TxmlNode)
... etc
rss.AddItem(item)
End Method
or something like that. |
| ||
| Thanks Brucey! this is a working rss feed reader example, it has an error on closing, but it works :) |
| ||
| Nice :-) Just a couple of tweaks to make it happy to run on Mac : You need to remove wxLC_REPORT from the LCtr_ChannelItems create. Since you already have wxLC_LIST. You shouldn't connect to wxEVT_CLOSE_WINDOW and then in the event handler called Window.Close(). Either, don't connect at all (it will automagically quit the app when the last window is closed), or instead call Window.Destroy(). :o) |
| ||
| Try using this as the rss feed: http://www.nytimes.com/services/xml/rss/nyt/Technology.xml Is there a way it can be a normal listbox (going down, instead of going on to the right)? EDIT: wxHtmlWindow updated version, includes another problem, when displaying the description the image does not show, however in firefox (opening the "test.html" file) shows everything correctly. |
| ||
| Yes this data in the wrong column business vexed me as well. Never really found the solution. This (sort of) works. [edited to add hscrollbar] Oh, and you lose the first item, (it's in the invisible header) - so either dummy first item or create the header outside the for-next I guess. |
| ||
This will show them all: Local row:Int
Local ritem:rssItem, wxl:wxListItem = New wxListItem.Create()
wxl.SetData(Null) wxl.SetText("") wxl.SetId(row) wxl.SetColumn(0)
LCtr_ChannelItems.InsertColumnItem(0, wxl)
row:+1
For ritem = EachIn rchan.chnItems
wxl:wxListItem = New wxListItem.Create()
wxl.SetData(ritem) wxl.SetText(ritem.Title)
wxl.SetId(row) wxl.SetColumn(0)
LCtr_ChannelItems.InsertItem(wxl)
row:+1
Print ritem.Description
Next |
| ||
Or evenLocal row:Int = 1 LCtr_ChannelItems.InsertColumnItem(0, New wxListItem.Create()) :-) No idea re that other problem though. I'm seeing an image in Leopard? I did read somewhere on the wxWidgets lists that wxHtmlWindow was considered a little flakey. Not what we want to hear I know. |
| ||
| I can't currently test it in Ubuntu, and I don't have a mac. |