Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vincent Bechu
jio
Commits
ac07621c
Commit
ac07621c
authored
Oct 17, 2017
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ParserStorage: handle text element
parent
d01cebe1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
src/jio.storage/parserstorage.js
src/jio.storage/parserstorage.js
+8
-5
test/jio.storage/parserstorage.tests.js
test/jio.storage/parserstorage.tests.js
+4
-0
No files found.
src/jio.storage/parserstorage.js
View file @
ac07621c
/*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,8 +19,10 @@
...
@@ -19,8 +19,10 @@
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
];
if
(
tag_element
.
nodeType
===
Node
.
ELEMENT_NODE
)
{
result
[
tag_element
.
tagName
]
=
tag_element
.
textContent
;
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
test/jio.storage/parserstorage.tests.js
View file @
ac07621c
...
@@ -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>
'
+
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment