Jump to content


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


Urgent Help: Accesing tags in SimpleXMLElement

Recommended Posts

Hello everybody,

I'm working with SimpleXMLElement to generate an xml file, but I'm having a problem, because all my tag names (odt xml files) have colons and dashes on it, for example: office:automatic-styles or style:style. the problem is because I use the following 'convention' to create child tags:

[code]$vendor = $xml-> mobil[0] -> addChild('vendor', 'Johnny');[/code]

where mobil[0] is the first tag named mobil on the root tag.

so If I want to add a new tag that has the name: office:automatic-styles, how could I scape the colon and the dash? if I write this:

[code]$style = $xml-> office:automatic-styles[0] -> addChild('style:style', '');[/code]

I get a bunch of errors.

I tried to scape them using a \ before each of these characters, but this didn't help.

Does anyone know what should I do?
I tryed putting the name of the tag in a string, but this does nothing, doesn't create the tag y the xml, nor throws any error message.

Help would be very appreciated.

Share this post

Link to post
Share on other sites


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.