What I'm trying to get is an array that contains all the description value like this :
var myArray = ['First Description', 'Second Description', 'Third Description']
So, I'm doing a request to an API and I read my value like this :
const xmlDoc = new DOMParser().parseFromString(xmlStr, "application/xml");
let firstDescription = xmlDoc.evaluate('Response/QueryListResponse/DomainEntity/Property[1]/value/text()')
console.log(firstDescription.stringValue) -- Display : First Description
But the problem with this solution is that I have only one description. So I tried to get a dom element and to navigate into it
So with this code :
x = xmlDoc.getElementsByTagName("QueryListResponse")[0];
I got a DOM element with all the values like this :
<QuerySelector>
<MetaData></MetaData>
<DomainEntity>
<Property path="description">
<Value>First Description</Value>
</Property>
</DomainEntity>
<DomainEntity>
<Property path="description">
<Value>Second Description</Value>
</Property>
</DomainEntity>
<DomainEntity>
<Property path="description">
<Value>Third Description</Value>
</Property>
</DomainEntity>
</QuerySelector>
So to get all my description I had two idea ...
The first one is to use the first solution and to use a for like this :
for (i; i <= nbOfValues; i++) {
let v = xmlDoc.evaluate('Response/QueryListResponse/DomainEntity/Property['+i+']/value/text()')
myArray += v.stringValue
}
But I don't know how to find the nbOfValues .
So I think the solution of the DOM element is easier.
I think I have to do something like document.getElementByPath('description)' but it didn't work.
Any idea?