PHP Classes

Attributes

Recommend this page to a friend!

      Clean XML To Array  >  All threads  >  Attributes  >  (Un) Subscribe thread alerts  
Subject:Attributes
Summary:Bug: If only the first Tag includes an Attribute ...
Messages:3
Author:Michael Beyer
Date:2007-08-02 06:28:21
Update:2007-08-24 15:46:38
 

  1. Attributes   Reply   Report abuse  
Picture of Michael Beyer Michael Beyer - 2007-08-02 06:28:22
Hi,

thank you for this wonderful Class. It's the best i could found for my cases. But i think i've found an bug:

This Example-XMl:
<?xml version="1.0" encoding="utf-8"?>
<test>
<mores>
<more test="true">one</more>
<more>two</more>
</mores>
<mores>
<more>three</more>
</mores>
<onlyone>
<one with="true">something</one>
</onlyone>
</test>

This will result in:
$xml_[mores][0][more][0] = "one"
$xml_[mores][0][more][1] = "two"
$xml_[mores][0][more-ATTR][test] = "true"
$xml_[mores][1][more] = "three"
$xml_[onlyone][one] = "something"
$xml_[onlyone][one-ATTR][with] = "true"

As you can see is the missing [0] failing for the tag [more-ATTR].

This is always so if the first tag has an attribut and the following not.
If the following tags have also an attribut, it's no problem.

What do you mean?

P.S.: Sorry for my unprofessional english ;-)

  2. Re: Attributes   Reply   Report abuse  
Picture of Michael Beyer Michael Beyer - 2007-08-03 06:11:51 - In reply to message 1 from Michael Beyer
Hello,

i've solved my/the problem with following code-snippet. This is surely not the best way to do that but i needed a solution. Perhaps it's an tipp for you to solve it the correct way.


// it's the first attribut;
if(!isset($this->pOut[key($this->track)][$tag.'-ATTR'])) {
if ($this->tmpAttrLevel[($this->tmpLevel - 1)]['attrLevel'] > 0) { $this->pOut[key($this->track)][$tag.'-ATTR'][0] = $attr;
} else {
$this->pOut[key($this->track)][$tag.'-ATTR'] = $attr;
}
// or it's not the first;
} else {
$this->pOut[key($this->track)][$tag.'-ATTR'][$this->tmpAttrLevel[$this->tmpLevel]['attrLevel']] = $attr;
}



Something other. When i'm using empty tags (without value inside), then the pointer (like {{3}}) keeps as value. How can i get the empty value (='')?. I don't want the pointer.


Thanks.

Best regards

noyannick

  3. Re: Attributes   Reply   Report abuse  
Picture of Ivan Enderlin Ivan Enderlin - 2007-08-24 15:46:38 - In reply to message 2 from Michael Beyer
Hey there :)

I'm back from holidays, sorry for this late response.
If you don't want to have a pointer, you can enter a blank char (&nbsp; for example). I don't work any more on this package. I upgrated to PHP 5, and I don't need this package as well :) But why not ameliorate it on day. I don't know.

For the problem of [0] index, it's a choice. I mean, I didn't want to have $var[0]['value'][0]['otherValue'][0] ... That's why I just write index for multi-tags, and not for one tag.

I'm tired and I think my english is bad today haha. Hope you understand me, and sorry for my late response.