JamAndJammies JamAndJammies - 2 years ago 113
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>

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download