|
Toni Test - 2008-04-08 14:49:16
Thanks for the class.
For a project where the same code should run on PHP 4 and 5 I tried the class and get the error message
Cannot use string offset as an array
The xml file was:
<Test id="1">the test text</Test>
Therefore I changed the code:
if($array[$i]["value"])
if($array[$i]["attributes"]) {
array_push($tags,"@content");
$this->array_insert(count($tags),$tags,$array[$i]["value"]);
array_pop($tags);
} else
$this->array_insert(count($tags),$tags,$array[$i]["value"]);
The result array looks like this:
Array
(
[@content] => the test text
[@attributes] => Array
(
[id] => 1
)
)
Taha Paksu - 2008-04-08 19:49:17 - In reply to message 1 from Toni Test
Thank you for writing your correction here and using my code. Can you mail me the full class or where you changed so I can update this script for people who will use this script too? Thanks again.
Toni Test - 2008-04-08 22:17:30 - In reply to message 2 from Taha Paksu
The first and the last line are from the old code (line 65 and 66):
if($array[$i]["value"])
$this->array_insert(count($tags),$tags,$array[$i]["value"]);
Insert the new code between those two lines:
if($array[$i]["attributes"]) {
array_push($tags,"@content");
$this->array_insert(count($tags),$tags,$array[$i]["value"]);
array_pop($tags);
} else
Taha Paksu - 2008-04-08 23:39:31 - In reply to message 3 from Toni Test
Yes I tried your code but it only works in tags which has only one attribute. So i fixed it and while fixing, i found another thing in this script. Recent fixes are;
- It can now display tags with empty values like 0,"",
- It had a repeating tags problem in which tags are same name but different levels, it's now corrected.
- It can now handle single tags with/without values and also XML like this :
<data caption="block" ca="ba">
test text
<test>csdafaba</test>
<test>caba</test>
</data>
I'm updating the code so pls use the updated one :)
Toni Test - 2008-04-09 08:07:34 - In reply to message 4 from Taha Paksu
Cool :-)
I will send you a reworked version of the class via mail. It returns XML error messages in case of invalid XML documents, uses @content instead of value because 'value' could be a tag name, and so more...
Taha Paksu - 2008-04-09 12:46:00 - In reply to message 5 from Toni Test
Ok but if you use PHP5, please try the same XML file with SimpleXML and look if there are no differences between them. It should be the main concept of this class. People shouldn't rewrite their code for using our class as a substitute of simplexml functions.
|