Wednesday, October 31, 2012

xml tag with one attribute and one value

Hello ... and thank you so very much for assisting!

The core libraries > utilities > xml documentation seems to imply that I can return the value of a tag's text by using '@' as the key. See following, straight from the documentation:

===============================

<?php
$xmlArray = array(
    'project' => array(
        '@id' => 1,
        'name' => 'Name of project, as tag',
        '@' => 'Value of project'
    )
);
$xmlObject = Xml::fromArray($xmlArray);
$xmlString = $xmlObject->asXML();
The content of $xmlString will be:

<?php
<?xml version="1.0"?>
<project id="1">Value of project<name>Name of project, as tag</name></project>

===============================

This is definitely what I would like to do, but whenever I use '@' as a key, I get a major page full of errors.

I would like to return something like: <project id="1">Value of project</project> (with no child tags)

In fact, and this is probably a different issue, I would really like to return: 

<projects>
<project id="1">Value of project</project>
<project id="2">Value of project</project>
<project id="3">Value of project</project>
<project id="4">Value of project</project>
</projects>

Again, thank you!!!

Kevin

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: