Extract multiple XML nodes at the same level with the same name?

Just starting out? Need help? Post your questions and find answers here.
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Extract multiple XML nodes at the same level with the same name?

Post by Quin »

I'm attempting to parse RSS feeds in my application using PB's XML library, and hitting a snag. I can get info like the title, author, description, link, etc., all super easily. However, each entry is wrapped inside a <item> element. How can I iterate through these and parse them? When I did a similar thing in C++ using the Poco libraries, I used Poco::DOMParser::getElementsByTagName, which returns a pointer to a list of nodes. PB's XML library doesn't seem to be able to do something like this though unless I'm missing it. Do I maybe have to call out to expat itself?
Thanks in advance,
Quin.
User avatar
kenmo
Addict
Addict
Posts: 2051
Joined: Tue Dec 23, 2003 3:54 am

Re: Extract multiple XML nodes at the same level with the same name?

Post by kenmo »

PB doesn't return a list of XML nodes, but you can absolutely iterate through them a couple of ways.

One way is N = XMLChildCount(*Parent), then For i = 0 to N-1, *Child = ChildXMLNode(*Parent, i)...

Another way is *Child = ChildXMLNode(*Parent), parse it, then move on to *Child = NextXMLNode(*Child) in a loop...

Maybe other ways too. ExtractXML() and related functions, but you'd have to set up structures first that match your RSS structure...
Post Reply