I have following string. I don't know whether I call it XML format or not. That's why I have used the word partially XML. Please correct me if I have used wrong terminology.

```
<grid name=\"resultset\" object=\"1\" jump=\"name\" select=\"1\" icon=\"1\" preview=\"1\">
    <row name=\"result\" id=\"accountid\">
        <cell name=\"name\" width=\"300\" />
        <cell name=\"telephone1\" width=\"100\" />
        <cell name=\"primarycontactid\" width=\"150\" />
        <cell name=\"accountprimarycontactidcontactcontactid.emailaddress1\" width=\"150\" disableSorting=\"1\" />
        <cell name=\"statecode\" width=\"100\" />
    </row>
</grid>

```

I want to get values of `name` attribute from `cell` tag `i.e name, telephone1, primarycontactid, accountprimarycontactidcontactcontactid.emailaddress1, statecode`

Can anybody suggest me how to get above values using javascript or jquery?

Error after applying following cocept: This happens if number of elements are more

```
var str = "<grid name=\"resultset\" object=\"1\" jump=\"name\" select=\"1\" icon=\"1\" preview=\"1\"><row name=\"result\" id=\"accountid\"><cell name=\"name\" width=\"300\" /><cell name=\"telephone1\" width=\"100\" /><cell name=\"primarycontactid\" width=\"150\" /><cell name=\"accountprimarycontactidcontactcontactid.emailaddress1\" width=\"150\" disableSorting=\"1\" /><cell name=\"statecode\" width=\"100\" /></row></grid>";

var tmpDiv = document.createElement('div');
tmpDiv.innerHTML = str;

var cells = tmpDiv.getElementsByTagName('cell')
var values = [];

for(var i = 0; i<cells.length; i++) {
  values.push(cells[i].getAttribute('name'));
}

```

Screenshot
[![enter image description here](https://i.stack.imgur.com/X0dNg.png)](https://i.stack.imgur.com/X0dNg.png)