Re: Re: XML_Serializer - flexible node attributes?
| From: | Guillaume Lecanu | Date: | Mon, 19 Dec 2005 08:38:12 +0000 |
| Subject: | Re: Re: XML_Serializer - flexible node attributes? | ||
| References: | 1 2 3 4 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22303@lists.php.net to get a copy of this message | ||
Le dimanche 18 décembre 2005 à 22:22 -0500, Stephen Musgrave a écrit :
> Andrew -
>
> Thanks for the simplexml tip, I hadn't yet made it to that point, but
> as soon as I ran into the problem, you suggestion came in handy.
>
> However, I am still having trouble with my need to create a node with
> both sub-nodes and attributes. I don't quite see how attributesArray
> would handle it - it seems like all or nothing.
>
> Here is an example what I am trying to accomplish:
>
> ...
> <ExchangeVisitor requestID="96" userID="userID"
> printForm="1">
> <LastName>bbbb</LastName>
> <FirstName>aaaa</FirstName>
> </ExchangeVisitor>
> ...
>
> But if I use attributesArray it also wants to put LastName and
> FirstName as an attribute to the ExchangeVisitor. I only want
> requestID, userID, printForm as attributes and everything else as
> sub-nodes.
>
> Any ideas? Examples?
I'm not sure to well understand (my english is bad sorry)
but your example could be make like this with XFC (XML_FastCreate) :
$x->ExchangeVisitor(array('requestID'=>'96',
userID'=>'userID',
'printForm'=>'1'),
$x->LastName('bbbb'),
$x->FirstName('aaaa')
)
Re-explain me if I haven't understand your problem
>
> Thanks!
>
>
> On Dec 16, 2005, at 3:26 PM, Andrew Nagy wrote:
>
> > Andrew Nagy wrote:
> >> Stephen Musgrave wrote:
> >>> Someone had responded to the thread, explaining that they should use
> >>> XML_FastCreate instead.
> >> Yes, I am in the process of switching my XML_Serializer object over
> >> to an XML_FastCreate because I don't think there is anyway to have
> >> multiple elements at one level with the same name due to the nature
> >> of associative arrays.
> >> It looks like XML_FastCreate can accomplish what you need to do.
> >
> > Scratch that idea, I am sticking with XML_Serializer. XML_FastCreate
> > will not allow the use of ':' in an element name (commonly used with
> > namespaces) due to the nature of object variables.
> >
> > Also, I figured out how to allow multiple elements at one level with
> > the same name. You can set everything in a subarray and use the
> > "simplexml" option.
> >
> > Andrew
> >
> >
> >
>