0

Hi I know there is plenty information in the web how to access objects in javascript objects. But those examples didn't help with the object in a format returned by the console node = xpath.select("//unit/object[@name='parProgramModeDefault']/@comment",doc);

When printed into the console the object looks like this:

console.log(res);:

enter image description here

How to access nodeName for example? This res.nodeName returns undefined

1
  • 1
    There's no generic solution and it has nothing to do with the console. You need to look to the documentation of the xpath module you are using, in order to learn how to use its return values. Commented Jan 11, 2017 at 11:51

2 Answers 2

2

In this specific instance, it's returning and you're logging an array, where the first (and only) entry in that array appears to be an object of type Attr. You can access nodeName via res[0].nodeName.

Sign up to request clarification or add additional context in comments.

Comments

1

pick up first array res[0].propertyName or you can do same by looping too

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.