Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

get a part of a string in an array

get a part of a string in an array


I am currently using nodejs and I have a function which return a body (String) its like this :


So I want to get all the FIRST name part (without the quotes) from this string and put it in an array or a list (in javascript), like here I would like to have :


I tried several way but it's not working, could you help me ? Thanks !

Problem courtesy of: Louis


Using xml2js:

var xml2js = require('xml2js'),
    parser = new xml2js.Parser();

parser.parseString(body, function(err, result) {
  var names = {
    return resourceDescriptor['@'].name;
  // => [ 'AllAccounts', 'Cascading_multi_select_report' ]

Note: I'm not that familiar with xml2js, there might be better libraries out there, especially if you need to parse large documents.

Solution courtesy of: Linus Gustav Larsson Thiel


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

get a part of a string in an array


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription