JamAndJammies JamAndJammies - 10 months ago 39
Node.js Question

How can I extract tag names from XML

I would like to extract the month in here, such that the characters after d: So I can get BC_1MONTH.

<d:BC_1MONTH m:type="Edm.Double">0.11</d:BC_1MONTH>


If the XML is loaded as a string, you can use regular expressions to match the value between d: and m:.

var str = xml;
var matches = xml.match(/d:(.*)\sm:/);

// get the first match group
console.log(matches[1]); // BC_1MONTH