2009年8月17日星期一

[fw-mvc] Re: [fw-general] [fw-mvc] - Zend_Config_Xml with attributes

Hi,

Yes it is possible, the attributes are the same as if you had a child element of the same name. For example:

<mydata>
<items type="clothes">
<item belongs_to="cat1">
<name>ABCD</name>
</item>
</items>
</mydata>

Is the same as if you did:

<mydata>
<items>
<type>clothes</type>
<item>
<belongs_to>cat1</belongs_to>
<name>ABCD</name>
</item>
</items>
</mydata>

Hope that helps,

Tom

2009/8/17 Vibhor Singh <vibhor@pivisions.net>

Hi all,

 

I want to use Zend_Config_Xml feature of ZF to automate my system. I am curious to know whether Zend_Config_Xml is able to read custom attributes of any xml file. If so, can someone please let me know how can this be achieved?

 

My xml file would look something like this:

 

<?xml version="1.0"?>

<mydata>

                <items type="clothes">

                <item belongs_to="cat1">

                                <name>ABCD</name>

                </item>

 

<item belongs_to="cat3">

                                <name>EFGH</name>

                </item>

</items>

 

<items type="shoes">

                <item belongs_to="cat5">

                                <name>PQRS</name>

                </item>

 

<item belongs_to="cat3">

                                <name>XYZ</name>

                </item>

</items>

 

</mydata>

 

Now suppose I want to access data under this node(<items type="shoes">), then how should I do this using the Zend_Config_Xml object.

Can someone please help me in this? Any help would be greatly appreciated.

 

Regards,

Vibhor

 

 


没有评论: