Commit ac07621c authored by Romain Courteaud's avatar Romain Courteaud

ParserStorage: handle text element

parent d01cebe1
/*jslint nomen: true*/ /*jslint nomen: true*/
/*global jIO, DOMParser */ /*global jIO, DOMParser, Node */
(function (jIO, DOMParser) { (function (jIO, DOMParser, Node) {
"use strict"; "use strict";
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
for (i = channel_element.childNodes.length - 1; i >= 0; i -= 1) { for (i = channel_element.childNodes.length - 1; i >= 0; i -= 1) {
tag_element = channel_element.childNodes[i]; tag_element = channel_element.childNodes[i];
result[tag_element.tagName] = tag_element.textContent; if (tag_element.nodeType === Node.ELEMENT_NODE) {
result[tag_element.tagName] = tag_element.textContent;
}
} }
return result; return result;
}; };
...@@ -94,7 +96,8 @@ ...@@ -94,7 +96,8 @@
for (i = element.childNodes.length - 1; i >= 0; i -= 1) { for (i = element.childNodes.length - 1; i >= 0; i -= 1) {
tag_element = element.childNodes[i]; tag_element = element.childNodes[i];
if (tag_element.tagName !== 'item') { if ((tag_element.nodeType === Node.ELEMENT_NODE) &&
(tag_element.tagName !== 'item')) {
result[tag_element.tagName] = tag_element.textContent; result[tag_element.tagName] = tag_element.textContent;
for (j = tag_element.attributes.length - 1; j >= 0; j -= 1) { for (j = tag_element.attributes.length - 1; j >= 0; j -= 1) {
...@@ -200,4 +203,4 @@ ...@@ -200,4 +203,4 @@
jIO.addStorage('parser', ParserStorage); jIO.addStorage('parser', ParserStorage);
}(jIO, DOMParser)); }(jIO, DOMParser, Node));
\ No newline at end of file \ No newline at end of file
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
var txt = '<?xml version="1.0" encoding="UTF-8" ?>' + var txt = '<?xml version="1.0" encoding="UTF-8" ?>' +
'<rss version="2.0">' + '<rss version="2.0">' +
'<channel>' + '<channel>' +
// Add a text element to ensure xml parser handle it
' ' +
'<title>RSS Example</title>' + '<title>RSS Example</title>' +
'<description>This is an example of an RSS feed</description>' + '<description>This is an example of an RSS feed</description>' +
'<link>http://www.domain.com/link.htm</link>' + '<link>http://www.domain.com/link.htm</link>' +
...@@ -64,6 +66,8 @@ ...@@ -64,6 +66,8 @@
'<opml version="1.0">' + '<opml version="1.0">' +
'<head>' + '<head>' +
'<title>feedOnFeeds.xml</title>' + '<title>feedOnFeeds.xml</title>' +
// Add a text element to ensure xml parser handle it
' ' +
'<dateCreated>Thu, 12 Sep 2003 23:35:52 GMT</dateCreated>' + '<dateCreated>Thu, 12 Sep 2003 23:35:52 GMT</dateCreated>' +
'<dateModified>Fri, 12 Sep 2003 23:45:37 GMT</dateModified>' + '<dateModified>Fri, 12 Sep 2003 23:45:37 GMT</dateModified>' +
'<ownerName>SomeUser</ownerName>' + '<ownerName>SomeUser</ownerName>' +
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment