疯狂疯狂/cs-phpxml

用于通过PHP读取、写入和更新XML的库

v1.2.0 2017-09-01 16:36 UTC

This package is not auto-updated.

Last update: 2024-09-21 11:33:07 UTC


README

xmlParser{} 是解析XML文件或字符串的类。

xmlBuilder{} 将数组(如 xmlParser{}->get_tree() 返回的数组)解析为XML字符串。

xmlCreator{} 是一组方法,用于创建与 xmlParser{} 创建的数组类似的对象,并将其提供给 xmlBuilder{} 以创建可用的XML字符串。

外部库

1.) "arrayToPath{}" 对象/类可在以下网址找到: http://sf.net/projects/cs-arraytopath,或通过Subversion在 "https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk"。

2.) 所有使用这些XML库的项目都有一个名为"/lib"的目录(位于"public_html"之下,其中包含index.php等文件),它包含所有库:/lib/externals/ 包含包含这些库的目录。以下是一个示例布局

/public_html/
	index.php
	subdir1/
	subdir2/
/lib/
	dir1/
	externals/
		cs-arrayToPath/
		cs-content/
		cs-phpxml/
	otherFolder/
/templates/
	somedir1/
	x/

3.)

注意:

1.) 只能有一个根元素(第一个索引,“ROOT_ELEMENT”)。

2.) 解析器将标签转换为大写:小写索引是特殊的:属性、类型、值)

3.) arrayToPath{} 使用路径来引用数组,就像Unix文件系统一样。在下面的数组中,具有 "AA Rechargeable Battery Pack" 值的标签可以表示为 "/ROOT_ELEMENT/SHOPPING-CART/ITEMS/ITEM/0/ITEM-NAME"。

4.) 如果同一父标签内列出了多个标签,则将它们表示为重复标签名下的数字索引数组:此父标签将不会有 "type" 索引。以下面的 /ROOT_ELEMENT/SHOPPING-CART/ITEMS/ITEM 为例。

5.) 属性名保留其原始大小写,不转换为大写或小写,就像其他人一样!

数组格式:

数组([ROOT_ELEMENT] => 数组([type] => open [attributes] => 数组([XMLNS] => http://this.domain.com/wherever/whatever [COMMENT] => This is my comment))

         [SHOPPING-CART] => Array
             (
                 [type] => open
                 [ITEMS] => Array
                     (
                         [type] => open
                         [ITEM] => Array
                             (
                                 [0] => Array
                                     (
                                         [type] => open
                                         [ITEM-NAME] => Array
                                             (
                                                 [type] => complete
                                                 [value] => AA Rechargeable Battery Pack
                                             )

                                         [ITEM-DESCRIPTION] => Array
                                             (
                                                 [type] => complete
                                                 [value] => Battery pack containing four AA rechargeable batteries
                                             )

                                         [UNIT-PRICE] => Array
                                             (
                                                 [type] => complete
                                                 [attributes] => Array
                                                     (
                                                         [CURRENCY] => USD
                                                         [testValue] => this is just a Test.
                                                     )

                                                 [value] => 12.00
                                             )

                                         [QUANTITY] => Array
                                             (
                                                 [type] => complete
                                                 [value] => 1
                                             )

                                     )

                                 [1] => Array
                                     (
                                         [type] => open
                                         [ITEM-NAME] => Array
                                             (
                                                 [type] => complete
                                                 [value] => MegaSound 2GB MP3 Player
                                             )

                                         [ITEM-DESCRIPTION] => Array
                                             (
                                                 [type] => complete
                                                 [value] => Portable MP3 player - stores 500 songs
                                             )

                                         [UNIT-PRICE] => Array
                                             (
                                                 [type] => complete
                                                 [attributes] => Array
                                                     (
                                                         [CURRENCY] => USD
                                                     )

                                                 [value] => 178.00
                                             )

                                         [QUANTITY] => Array
                                             (
                                                 [type] => complete
                                                 [value] => 1
                                             )

                                     )

                             )

                     )

             )

     )

)

许可证

版权(c)2013 "疯狂疯狂" Dan Falconer。在MIT和GPL许可证下双许可。