How to parse an xml string in javascript? (not client-side, browser-related)

goldenboolean

New Member
I was wondering if anybody could point me to a Core (not client-side) JavaScript solution for parsing an xml string. For example, turning it into an object I could pluck properties out of. Or even an array.I've searched high and low, and all the solutions I see are client-side solutions which make use of a particular browser's DOM. Please note, I am programming in JavaScript, but this is not a DOM-related question. It's a server-side calculation.For example, I have this string:
\[code\]<IndustryTerm count="2" relevance="0.553">food system</IndustryTerm><Person count="2" relevance="0.586">Alexandra Spieldoch</Person><Event count="1">Environmental Issue</Event><IndustryTerm count="1" relevance="0.154">rural finance</IndustryTerm><IndustryTerm count="1" relevance="0.335">food security</IndustryTerm><IndustryTerm count="1" relevance="0.280">e-consultation</IndustryTerm><IndustryTerm count="1" relevance="0.154">high-level food security dialogues</IndustryTerm><IndustryTerm count="1" relevance="0.154">food markets</IndustryTerm><Position count="1" relevance="0.335">representative</Position><SocialTags><SocialTag importance="2">Sociology<originalValue>Sociology</originalValue></SocialTag><SocialTag importance="2">Food security<originalValue>Food security</originalValue></SocialTag><SocialTag importance="1">Food politics<originalValue>Food politics</originalValue></SocialTag><SocialTag importance="1">Gender<originalValue>Gender</originalValue></SocialTag><SocialTag importance="1">Biology<originalValue>Biology</originalValue></SocialTag></SocialTags>\[/code\]My goal is to find all the relevance and importance values, and the associated values between the tags. To be more specific, in this case:\[code\]<IndustryTerm count="1" relevance="0.154">food markets</IndustryTerm>\[/code\]I'd like to know the tag name (IndustryTerm) the relevance (0.154) and the the value between the open and close tags (food markets).I've been fiddling around with regular expressions, but haven't been able to "hit the spot" yet and was just wondering if there is something out there.Again, this is not related to client-side JavaScript or browsers, but does need to be in standard, Core JavaScript.doug
 
Back
Top