xml-parser
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -83,3 +83,3 @@ | ||
// attributes | ||
while (!(eos() || is('>') || is('?>'))) { | ||
while (!(eos() || is('>') || is('?>') || is('/>'))) { | ||
var attr = attribute(); | ||
@@ -90,2 +90,7 @@ if (!attr) return node; | ||
// self closing tag | ||
if (match(/^\s*\/>\s*/)) { | ||
return node; | ||
} | ||
match(/\??>\s*/); | ||
@@ -92,0 +97,0 @@ |
{ | ||
"name": "xml-parser", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"repository": "segmentio/xml-parser", | ||
@@ -15,5 +15,6 @@ "description": "the little xml parser that could", | ||
"mocha": "*", | ||
"should": "*" | ||
"should": "*", | ||
"matcha": "~0.4.1" | ||
}, | ||
"license": "MIT" | ||
} |
# xml-parser | ||
Simple non-compiant XML parser because we just need to parse some basic responses and libxml takes forever to compile ;D | ||
Simple non-compiant XML parser because we just need to parse some basic responses and libxml takes forever to compile :D you probably don't want to use this unless you also have similar needs. | ||
@@ -6,0 +6,0 @@ ## Installation |
@@ -123,1 +123,58 @@ | ||
it('should support self-closing tags', function () { | ||
var node = parse('<a><b>foo</b><b a="bar" /><b>bar</b></a>'); | ||
node.root.should.eql({ | ||
"name": "a", | ||
"attributes": {}, | ||
"children": [ | ||
{ | ||
"name": "b", | ||
"attributes": {}, | ||
"children": [], | ||
"content": "foo" | ||
}, | ||
{ | ||
"name": "b", | ||
"attributes": { | ||
"a": "bar" | ||
}, | ||
"children": [] | ||
}, | ||
{ | ||
"name": "b", | ||
"attributes": {}, | ||
"children": [], | ||
"content": "bar" | ||
} | ||
], | ||
"content": "" | ||
}) | ||
}) | ||
it('should support self-closing tags without attributes', function () { | ||
var node = parse('<a><b>foo</b><b /> <b>bar</b></a>'); | ||
node.root.should.eql({ | ||
"name": "a", | ||
"attributes": {}, | ||
"children": [ | ||
{ | ||
"name": "b", | ||
"attributes": {}, | ||
"children": [], | ||
"content": "foo" | ||
}, | ||
{ | ||
"name": "b", | ||
"attributes": {}, | ||
"children": [] | ||
}, | ||
{ | ||
"name": "b", | ||
"attributes": {}, | ||
"children": [], | ||
"content": "bar" | ||
} | ||
], | ||
"content": "" | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
21976
13
314
3
2