Another route (there are always millions of ways of doing this kind of thing): $sXML = '<?xml version="1.0" encoding="UTF-8"?><computer><general><id>000</id><name>MyMachine</name></general><software><licensed_software><name>Adobe Acrobat Pro XI</name><name>Adobe Acrobat X</name><name>Adobe Illustrator CS6</name><name>Google Chrome</name><name>Microsoft Office</name><