You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you're listening for the 'data' event, which is never emitted, because you don't use the write method. :P
you can find a list of all events here: https://github.com/dodo/node-asyncxml#events
asyncxml=require('asyncxml')streamify=require('dt-stream')xml=newasyncxml.Builder({pretty:true});streamify(xml).stream.on('data',function(chunk){console.log(chunk);});// build some xmlxml.tag("xml",{version:"1.0"}).tag("list").tag("entry",function(){this.attr('id',1)}).up().tag("entry",{id:2},"foo").up().up().end()
please note that it will raise a warning because of the this.attr('id', 1) because the time its used the open tag of the first entry is already rendered and emitted as data, so its not possible to change it.
i did this to be able to stream faster (streaming can already start with the element opener).
i'm open for any suggestions to do this in a better way.
if you have any question, feel free to just shot them :)
My steps:
So i try run exmaple:
asyncxml = require('asyncxml')
xml = new asyncxml.Builder({pretty:true})
xml.on('data', function (chunk) {
console.log(chunk);
})
// build some xml
xml.tag("xml", {version:"1.0"})
.tag("list")
.tag("entry", function () {
this.attr('id', 1)
}).up()
.tag("entry", {id:2}, "foo").up()
.up()
.up()
.end()
but i can't see xml text in my terminal.
The text was updated successfully, but these errors were encountered: