Jump to content

SimpleXML help


jamiesalter

Recommended Posts

Hello all,

I'm having problems using simpleXML in PHP.  I am trying to assign an elements data to a variable.  Normally the following would work:

[color=blue]$xml = simplexml_load_file($file);

foreach ($xml->item as $item) {

$manu = trim(addslashes($item->manufacturer));
...
}[/color]

However my problem occurs when the elements name contains a colon.  For example, if instead of [color=blue]$item->manufacturer[/color] it was [color=blue]$item->g:brand[/color] php produces an error because of the colon producing an invalid variable name.  Is it possible to escape the colon somehow, whilst still instructing simpleXML to get the data of g:brand?

Any comments or help would be gratefully appreciated,

Jamie Salter
jbhhockey.co.uk
Link to comment
https://forums.phpfreaks.com/topic/25966-simplexml-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.