What I would do first is get your UIElement array in into its own array. So you will do something like this
const uiElmentArray = this.text['cm:property-placeholder']['cm:default-properties'][0]['UIInput'][0]['UIElement'];
/**
uiElementArray = [
{$: {id: 'customerName', ...}},
{$: {id: 'mm_test_aggregate.interval', ...}},
...
]
**/
From there you can map the contents to get rid of the $ from the array
const updatedArray = uiElementArray.map(uiElement => uiElement.$);
/**
updatedArray = [
{id: 'customerName', ...},
{id: 'mm_test_aggregate.interval', ...},
...
];
**/
From there you can loop through your elements to display them
updatedArray.forEach(uiElement => {
console.log(uiElment)
});
Making the final code look something like this:
showData() {
xml2js.parseString(this.xml, (err, result) => {
const uiElementArray = result['cm:property-placeholder']['cm:default-properties'][0]['UIInput'][0]['UIElement'];
const updatedArray = uiElementArray.map(uiElement => uiElement.$);
updatedArray.forEach(uiElement => {
console.log(uiElment)
});
})
}
which can be condensed down to something like this
showData() {
xml2js.parseString(this.xml, (err, result) => {
this.myData = result['cm:property-placeholder']['cm:default-properties'][0]['UIInput'][0]['UIElement'].map(uiElement => uiElement.$);
})
}
console.log(this.text['cm:property-placeholder']['cm:default-properties][0]['UIElement'][0]['$'])to get the object. then from there you addid,maxlength, etc to the end to get the individual elementsCannot read property '0' of undefinedcm:default-propertiesor theUIElementthat you were getting the error. I will update my answer as we figure things outUIInputlayer in my comment and my answer. I will update it