简体   繁体   English

如何在cakePHP1.3中编辑XML值?

[英]How to Edit XML value in cakePHP1.3?

I have XML resource which provide this: 我有提供此内容的XML资源:

<container>
    <element id="first-el">
        <name>My element</name>
        <size>20</size>
    </element>
    <element>
        <name>Your element</name>
        <size>30</size>
    </element>
</container>

What i want to do is to change value of <size> , where id is "first-el" , and change 20 to 50. 我想做的是更改<size>值,其中id"first-el" ,并将20更改为50。

The resulting XML should look like this: 生成的XML应该如下所示:

<container>
    <element id="first-el">
        <name>My element</name>
        <size>50</size>
    </element>
    <element>
        <name>Your element</name>
        <size>30</size>
    </element>
 </container>

I tried to use addChild() of XML Method in CakePHP, but is there a better way to do this? 我试图在CakePHP中使用XML方法的addChild() ,但是有更好的方法吗?

I have no idea what sort of additional functionality CakePHP provides in regards to XML, but there already tools for this in plain old PHP: 我不知道CakePHP在XML方面提供了什么样的附加功能,但是在普通的旧PHP中已经有用于此的工具:

Both let you manipulate existing XML data. 两者都允许您操纵现有的XML数据。

There is a class in CakePHP that will handle all of this for you. CakePHP中有一个类可以为您处理所有这些。 You can read the specifics here: 您可以在此处阅读详细信息:

CakePHP 1.3: http://book.cakephp.org/1.3/en/view/1485/Xml CakePHP 1.3: http//book.cakephp.org/1.3/en/view/1485/Xml

CakePHP 2.0: http://book.cakephp.org/2.0/en/core-utility-libraries/xml.html CakePHP 2.0: http//book.cakephp.org/2.0/en/core-utility-libraries/xml.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM