---
title: "jQuery get multiple nodes with same name in xml"  
description: "jQuery get multiple nodes with same name in xml"  
author: "Anonymous User"  
published: 2014-11-06  
updated: 2014-11-06  
canonical: https://www.mindstick.com/forum/2526/jquery-get-multiple-nodes-with-same-name-in-xml  
category: "xml"  
tags: ["ajax", "jquery", "javascript"]  
reading_time: 1 minute  

---

# jQuery get multiple nodes with same name in xml

I have a part of an [XML file](https://www.mindstick.com/forum/360/how-to-read-xml-file-in-php) that looks like this:

```
<paymentTypes>
<paymentType>type1</paymentType>
<paymentType>type2</paymentType>
<paymentType>type3</paymentType>
<paymentType>type4</paymentType>
</paymentTypes>
```

The thing is that I want to get it via [ajax](https://www.mindstick.com/articles/1541/check-availability-of-user-name-or-email-using-asp-dot-net-ajax-and-jquery) jQuery, but if I try this:

```
var paymentTypes = $(xml).find("paymentTypes").text()
```

the [output](https://www.mindstick.com/interview/34427/explain-the-output-in-angular) will be type1type2type3type4.

What [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) should I use(built-in or should I write it) in [order](https://www.mindstick.com/articles/12276/how-timely-order-deliveries-can-improve-customer-experience) to get the [results](https://yourviews.mindstick.com/story/4497/usage-of-baking-soda-magical-results) on separate lines?

## Replies

### Reply by Mark Devid

u can iterate over the result append to new string\

```
var xml ='<paymentTypes><paymentType>type1</paymentType><paymentType>type2</paymentType><paymentType>type3</paymentType><paymentType>type4</paymentType></paymentTypes>'; var result = "";$(xml).find('paymentType').each(function(i,v){    result += $(v).text()+'\n';});console.log(result);
```


---

Original Source: https://www.mindstick.com/forum/2526/jquery-get-multiple-nodes-with-same-name-in-xml

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
