PHP Classes

Parse behavoir

Recommend this page to a friend!

      Clean XML To Array  >  All threads  >  Parse behavoir  >  (Un) Subscribe thread alerts  
Subject:Parse behavoir
Summary:CDATA and empty tags
Messages:3
Author:Matthias Wetzel
Date:2007-11-01 10:38:56
Update:2007-11-01 23:33:50
 

  1. Parse behavoir   Reply   Report abuse  
Picture of Matthias Wetzel Matthias Wetzel - 2007-11-01 10:38:56
Hi,
two issues of parse behavior makes me headache:

Snippet of the XML File:

<datei>
<dat_nam>201303850_07_0000928_01</dat_nam>
<dat_typ>RE13</dat_typ>
<dat_obj_id>3599049</dat_obj_id>
<dat_dat>2007-09-04</dat_dat>
<dat_time>09:35:19</dat_time>
<dat_empf>120291466</dat_empf>
<dat_empf_name><![CDATA[Berufsgenossenschaft für Gesundheitsdienst und Wohl- Fahrtspflege/Bez-Verw Hmbg]]></dat_empf_name>
<dat_status>3</dat_status>
<dat_fehler>
<fehler_text><![CDATA[(Warnung) Unspezifizierte Meldung - Kommunikationspartnersystem [D2DASS] registriert Dokumentenpaket [201303850_07_0000928_01_RE13.zip] erneut - Dokumentenpaket wurde ignoriert.]]></fehler_text>
<fehler_feld_tech></fehler_feld_tech>
<fehler_feld_fach></fehler_feld_fach>
<fehler_code></fehler_code>
</dat_fehler>
</datei>

CDATA issue:
------------
The closing bracket ] in CDATA of tag <fehler_text> might be used as stop marker for CDATA, so the parse result looks like this

["fehler_text"]=>
array(3) {
[0]=>
string(71) "(Warnung) Unspezifizierte Meldung - Kommunikationspartnersystem [D2DASS"
[1]=>
string(63) "] registriert Dokumentenpaket [201303850_07_0000928_01_RE13.zip"
[2]=>
string(43) "] erneut - Dokumentenpaket wurde ignoriert."
}

I know, your class is only reacting on the internal XML parser result, but those brackets are allowed in CDATA entities. Do you have an idea, how to fix it?

Empty tag issue:
----------------
The parsing result of these empty tags

<fehler_feld_tech></fehler_feld_tech>
<fehler_feld_fach></fehler_feld_fach>
<fehler_code></fehler_code>

looks like this

["fehler_feld_tech"]=>
string(5) "{{3}}"
["fehler_feld_fach"]=>
string(5) "{{3}}"
["fehler_code"]=>
string(5) "{{3}}"

... might this be a bug in the class? This occurs in any empty tag, depending on the pointer value, the parse results will be "{{2}}", "{{3}}" an so on...

Thanks for you help
Matthias



  2. Re: Parse behavoir   Reply   Report abuse  
Picture of Matthias Wetzel Matthias Wetzel - 2007-11-01 15:35:08 - In reply to message 1 from Matthias Wetzel
BTW I fixed the CDATA issue by upgrading to PHP5... but this can't be my option, 'cause all our customer are using PHP4

  3. Re: Parse behavoir   Reply   Report abuse  
Picture of Ivan Enderlin Ivan Enderlin - 2007-11-01 23:33:50 - In reply to message 2 from Matthias Wetzel
Hey :)

Using my classe with PHP 5 doesn't any sense. PHP 5 has SimpleXML, powerful and fast module integrated by default in PHP written in C.
Normally, CDATA are correctly parsed by PHP 4 for me, I don't know where is the problem, sorry.

About empty tags, yes, we see pointers values. I decide to let pointers at the beginning, but you're not the first to tell me : hey, why you keep pointers values ? So, maybe I won't keep them.

But, I'm busy by an other big project : a framework in PHP 5 (http://hoa-project.net), and I don't update this class anymore, I'm sorry.

Hope helped you, good night.