I am still not able to figure out what the problem is.

On Wed, Feb 12, 2014 at 12:48 AM, Diogo Resende <[email protected]>wrote:

> 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:
>
> [image: Inline image 1]
>
>
> *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 == 'node') {
>       nodeCounter++;
>       elements_array.push({
>       group: 'nodes',
>       data: { id: node.attributes.id, label: node.attributes.label }
>       });
>
>     if (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 =='att') {
>       var key = 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]
> 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.
>
>
>  --
> --
> 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.
>



-- 
Anurag Prasad
Birla Institute of Technology & Science, Pilani
Pilani Campus
Pilani, India. 333 031
Mobile: +91 - 9001250705
E.mail: [email protected]
www.bits-pilani.ac.in

-- 
-- 
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.

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

Reply via email to