Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » XmlParser and <![CDATA[
Re: XmlParser and <![CDATA[ [message #21262 is a reply to message #21260] Mon, 11 May 2009 08:37 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14261
Registered: November 2005
Ultimate Member
ParseXML has second parameter that, in default form, makes it ignore anything but tags.

You can put there 0 to get all info from XML. Note, however, that in that case initial <? item also qualifies, so you can no longer use n[0].

#include <Web/Web.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	HttpClient client;
	client.URL("http://losangeles.craigslist.org/search/jjj?query=php&format=rss");
	String out = client.ExecuteRedirect();
	XmlNode n = ParseXML(out, 0);
	int q = n.FindTag("rdf:RDF");
	if(q >= 0) {
		const XmlNode& channel = n[q];
		for(int i = channel.FindTag("item"); i<channel.GetCount(); i++) {
			if(channel[i].GetTag() == "item") {
				const XmlNode &item=channel[i];
				int tag = item.FindTag("title");
				if(tag >= 0) {
					const XmlNode& title = item[tag];
					for(int j = 0; j < title.GetCount(); j++) {
						DUMP(title[j].GetType());
						DUMP(title[j].GetText());
					}
				}
			}
		}
	}
}


Mirek
 
Read Message
Read Message
Read Message
Previous Topic: Proposal: add Vector::InsertPick(int i, pick_ T&)
Next Topic: date filter bug?
Goto Forum:
  


Current Time: Sat Jun 07 17:54:23 CEST 2025

Total time taken to generate the page: 0.04466 seconds