Hi everyone. I am new to PHP and XML and would like to take the following example xml,

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<shirt>
<name>Long Sleved></name>
<link>index/1/1</link>
<Types>
<Type>
<name>blue</name>
<link>index/1/1/1/17743/60088</link>
</Type>
<Type>
<name>green</name>
<link>index/1/1/1/1/1</link>
</Type>
<Type>
<name>red</name>
<link>index/1/1/1/2/2</link>
</Type>
<Type>
<name>yellow</name>
<link>index/1/1/1/3/3</link>
</Type>
<Type>
<name>orange</name>
<link>index/1/1/1/4/4</link>
</Type>
       </Types>
</shirt>
<shirt>
<name>short sleved</name>
<link>index/1/1</link>
<Types>
<Type>
<name>light blue</name>
<link>index/1/1/1/17743/60089</link>
</Type>
<Type>
<name>green</name>
<link>index/1/2/1/1/1</link>
</Type>
<Type>
<name>red</name>
<link>index/1/2/1/2/2</link>
</Type>
<Type>
<name>yellow</name>
<link>index/1/2/1/3/3</link>
</Type>
<Type>
<name>orange</name>
<link>index/1/2/1/4/4</link>
</Type>
       </Types>
</shirt>

And display it on,screen using PHP in this format,

Long Sleved, blue, index/1/1/1/17743/60088
Long Sleved, green, index/1/1/1/1/1
Long Sleved, red, index/1/1/1/2/2
Long Sleved, yellow, index/1/1/1/3/3
Long Sleved, orange<, index/1/1/1/4/4
short sleved, light blue, index/1/1/1/17743/60089
short sleved, green, index/1/2/1/1/1
short sleved, red, index/1/2/1/2/2
short sleved, yellow, index/1/2/1/3/3
short sleved, orange<, index/1/2/1/4/4

My actual xml file is a lot bigger than the example but in the same format. I hope that someone can show me how to do this. Have tried using simpleXML dom functions and others but just cant seem to do it.
Thanks

Recommended Answers

All 2 Replies

there is a syntax error on the 3rd line, it could be why simpleXML isnt working

<name>Long Sleved></name>

No its not a syntax error in the xml. The code i provided is an example of my xml structure and i think i made the error when pasting it to the forum. I need to know how to pull the information out of the xml and place it into the above structure. When using xmlsimple i could only get the first name and link nodes from each type. I would like to get all of them.
Would like to cycle through each shirt and corresponding type and output it to the display like this.

Long Sleved, blue, index/1/1/1/17743/60088
Long Sleved, green, index/1/1/1/1/1
Long Sleved, red, index/1/1/1/2/2
Long Sleved, yellow, index/1/1/1/3/3
Long Sleved, orange<, index/1/1/1/4/4
short sleved, light blue, index/1/1/1/17743/60089
short sleved, green, index/1/2/1/1/1
short sleved, red, index/1/2/1/2/2
short sleved, yellow, index/1/2/1/3/3
short sleved, orange<, index/1/2/1/4/4

Thanks:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.