Page 1 of 1

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

Posted: Sat Oct 05, 2024 1:24 am
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.

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

Posted: Sat Oct 05, 2024 3:07 am
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...