Parsing XML, should I use SAX or DOM?
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I'm trying to parse some RSS feeds for my website, and I'm not really sure where to start. Can anyone recommend any tutorials or articles? Should I use SAX or DOM to do it?
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I recommend you legendary tutorial/faq web by Roseanne Zhang.
My opinion is to use JDOM, parsing this way...
My opinion is to use JDOM, parsing this way...
Chris Stewart
Ranch Hand
Posts: 184
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Ok, after some reading, here I am...
For some reason the node_x.getNodeValue call doesn't return the text, can anybody help me figure out why?
For some reason the node_x.getNodeValue call doesn't return the text, can anybody help me figure out why?
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
If I am remember correctly, the 'ELEMENT' node type has broader range. So can you check the nodetype static variable again and try 'TEXTNODE' or something like that? Hope this helps you.
Chris Stewart
Ranch Hand
Posts: 184
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
That didn't work for me either. :dunno:
[ July 21, 2003: Message edited by: Chris Stewart ]
[ July 21, 2003: Message edited by: Chris Stewart ]
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
in the inner most loop of your code, you got to the point where you can print the node name. For example, "title"
<title>Open source or no: Let the market decide</title>
The node you are examining at this point has a node name "title" and node value "null". I assume you are trying to print the text "Open source....".
It is represented by the child node and this child node has a node name "#text" (or null for some parsers) and the node value "Open source..."
To get your program working, get the child node, check it's Node type (Node.TEXT_NODE) and then get the NodeValue.
<title>Open source or no: Let the market decide</title>
The node you are examining at this point has a node name "title" and node value "null". I assume you are trying to print the text "Open source....".
It is represented by the child node and this child node has a node name "#text" (or null for some parsers) and the node value "Open source..."
To get your program working, get the child node, check it's Node type (Node.TEXT_NODE) and then get the NodeValue.
<a href="http://www.mqtips.com" target="_blank" rel="nofollow">MQMessenger</a> - free Java app for MQSeries
Chris Stewart
Ranch Hand
Posts: 184
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Perfect, thank you! This is my final code:
Naren
Greenhorn
Posts: 23
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
you can remove a lot of lines from your code using the call getElementsByTagName("tag_name").
I use this function to get the value of a node:
the 'for' loop inside is just to be safe with all sorts of parser implementations. The text value of the node is represented, some times, in multiple child nodes.
I use this function to get the value of a node:
the 'for' loop inside is just to be safe with all sorts of parser implementations. The text value of the node is represented, some times, in multiple child nodes.
<a href="http://www.mqtips.com" target="_blank" rel="nofollow">MQMessenger</a> - free Java app for MQSeries
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Moving to the XML forum.
"JavaRanch, where the deer and the Certified play" - David O'Meara
| Remember to always leap before you look. But always take the time to smell the tiny ads: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |










