Your “Code” part does not seem to have any problems, at least a missing “)”. 
You should really install a linter in your editor, you have unused vars and 
global pollution..

--  
Diogo Resende


On Tuesday 11 February 2014 at 19:14 , Anurag Prasad wrote:

>  
>  
>  
> Code->
>  
> var fs = require('fs');
> var sax = require('sax');
>  
> parser = sax.parser(true);
>  
> elements_array = [];  
> nodeCounter = -1;
>  
> parser.onerror = function(e) {
>     // an error happened.
>   };
>  
> parser.onopentag = function(node) {
>     // opened a tag. node has "name" and "attributes"
>     if (node.name (http://node.name) == 'node') {
>       nodeCounter++;
>       elements_array.push({
>       group: 'nodes',
>       data: { id: node.attributes.id (http://node.attributes.id), label: 
> node.attributes.label }
>       });
>  
>     if (node.name (http://node.name) == 'edge') {
>       nodeCounter++;
>       elements_array.push({
>       group: 'edges',
>       data: { label: node.attributes.label, source: node.attributes.source, 
> target: node.attributes.target }
>       });
>  
>     if (node.name (http://node.name) =='att') {
>       var key = node.attributes.name (http://node.attributes.name);
>       elements_array[nodeCounter].data.key = { type : node.attributes.type, 
> value: node.attributes.value};
>     };
>     };
>  
>   };
>  
>  parser.onend = function() {
>     // parser stream is done, and ready to have more stuff written to it.
>     console.log("XML has been parsed.\n");
>   };
>  
>  
> try {
>     var file_buf = fs.readFileSync('./graph.xml');
>     parser.write(file_buf.toString('utf8')).close();
> } catch(ex) {
>     // keep 'em silent
> }
>  
> console.log(elements_array);
>  
> --  
> --  
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected] 
> (mailto:[email protected])
> To unsubscribe from this group, send email to
> [email protected] 
> (mailto:[email protected])
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>   
> ---  
> You received this message because you are subscribed to the Google Groups 
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> (mailto:[email protected]).
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

<<attachment: Screen Shot 2014-02-12 at 12.41.30 AM.png>>

Reply via email to