Created
June 15, 2015 21:51
-
-
Save ariutta/4e2c6babe06eea43bc33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var strict = true; | |
var saxStream = sax.createStream(strict, {xmlns: true, encoding: 'utf8'}) | |
function createSaxStreamEventObservable(eventName) { | |
return Rx.Observable.fromEventPattern( | |
function addHandler (h) { | |
saxStream.on(eventName, h); | |
}, | |
function delHandler () {} | |
); | |
} | |
var responseSource = createSaxStreamEventObservable('opentag').filter(function(node) { | |
return node.name === 'ns1:updatePathwayResponse'; | |
}) | |
.flatMap(function(node) { | |
console.log('node1'); | |
console.log(node); | |
return createSaxStreamEventObservable('text').filter(function(text) { | |
console.log('text1'); | |
console.log(text); | |
return !_.isEmpty(text) && text !== ' '; | |
}).takeUntil(createSaxStreamEventObservable('opentag').concat(createSaxStreamEventObservable('closetag').filter(function(node) { | |
return node.name === 'ns1:updatePathwayResponse'; | |
})).map(function(ender) { | |
console.log('ender'); | |
console.log(ender); | |
}));; | |
}); | |
var myText; | |
responseSource.subscribe(function(text) { | |
console.log('text2'); | |
console.log(text); | |
myText = text; | |
}, function(err) { | |
console.log(err); | |
}); | |
highland(['<ns1:updatePathwayResponse xmlns:ns1="http://www.wso2.org/php/xsd" xmlns:ns2="http://www.wikipathways.org/webservice"> <ns1:success>80315</ns1:success> <ns1:fail>v</ns1:fail> <ns1:success> </ns1:success> <ns1:success>80316</ns1:success> </ns1:updatePathwayResponse>']) | |
.pipe(saxStream); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment