0

I have some xml that I have parsed using npms xml2js. It has a few namespaces in the xml and when I parse it and inspect the results I get this...

enter image description here

Cool. I can go to steps deep by doing this console.log(result['bpr:release']['bpr:contents']) which yeilds this..

enter image description here

Want I want to do now is try and drill into those child nodes like process and process group but I can't figure out how or find an documentation on it. I tried things like result['bpr:release']['bpr:contents'].process and result['bpr:release']['bpr:contents']['process'] and neither works. What's the proper way of doing this?

SonOfNye
  • 75
  • 8

2 Answers2

0

Try out the JSON stringify method:

console.log(JSON.stringify(result, null, 2));

I've found this will always fully display the output. The regular methods aren't reliable for getting nested objects.

0

It turns out I was just going down the wrong paths. This was the correct way...

result['bpr:release']['bpr:contents'][0]['process'][0]

Respect arrays

SonOfNye
  • 75
  • 8