# XML to Array

**URL:** <https://forum.kirupa.com/t/xml-to-array/310596>\
**Category:** Uncategorized\
**Created:** [June 14, 2010, 4:30pm UTC](https://forum.kirupa.com/t/xml-to-array/310596 "2010-06-14T16:30:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![humbucker](https://avatars.discourse-cdn.com/v4/letter/h/278dde/32.png) [@humbucker](https://forum.kirupa.com/u/humbucker)\
**Post date:** [June 14, 2010, 4:30pm UTC](https://forum.kirupa.com/t/xml-to-array/310596/1 "2010-06-14T16:30:33Z")

</div>

Hello!

I need to build an array based on this XML structure

```auto

		<student>
			<name></name>
			<pic></pic>
		</student>
		<student>
			<name></name>
			<pic></pic>
			<pic></pic>
			<pic></pic>
		</student>
		<student>
			<name></name>
			<pic></pic>
			<pic></pic>
		</student>

```

So that it would give me something like the image attached.

The complexity comes from the fact a “student” can have several “pic”.  
In my actual for loop, I get errors or only partial results.

Your ideas would be greatly appreciated.

I need to be able to always trace a given pic belongs to the student’s name.

Many many thanks!
