Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] XML parser

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Dec 2009 04:37 Edited at: 17th Dec 2009 04:40
Little project I started tonight, still a work in progress obviously. This little demo will parse the xml tags then display each tag name along with its parent's name. My next step will probably be to retrieve the inner content and after that the attributes.



Looking at the sample xml code, would the inner text of the painting tag "This is Raphael's "Foligno" Madonna, painted in"? Or would it include the inner text of all child nodes as well? "This is Raphael's "Foligno" Madonna, painted in 1511-1512."

p.s. Yes I'm aware there's a plugin for all this, but where's the fun in that?


> SELECT * FROM users WHERE clue > 0
> 0 rows returned
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Dec 2009 14:41
Wow, that's some crazy commenting you got going there.

Anyway, I saw "XML Parser" as the title and before I managed to look at the author I instantly thought "Phaelax". Is that weird or what?

Pretty cool though.

"everyone forgets a semi-colon sometimes." - Phaelax
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Dec 2009 17:55
I just lurk in the background and pop up with something new every now and then, just so I dont feel like a forum troll


> SELECT * FROM users WHERE clue > 0
> 0 rows returned
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 30th Dec 2009 18:26 Edited at: 30th Dec 2009 18:27
Here's an update, now retrieves the inner content from the tags. It's not 100% yet. As the tag's content does include the content from its child tags it's not including the text of the children's children..... if that makes sense. I'll need to build a recursive method most likely to handle this. I didn't touch this for a week when a convenient method for extracting inner text popped in my head. I just now got around to implementing it.

But now that I think about it, I have a better way now. I'll upload that after I get the attributes extracted.




> SELECT * FROM users WHERE clue > 0
> 0 rows returned
jeffhuys
17
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 31st Dec 2009 23:15
Impressive.
I like to program these kind of things, when you're done you feel so good, it's like an oiled machine .

You're the 'th to view this signature!

Login to post a reply

Server time is: 2024-04-19 17:07:43
Your offset time is: 2024-04-19 17:07:43