note 96224 deleted from book.dom by danbrown
| From: | danbrown@php.net | Date: | Tue, 16 Feb 2010 17:58:39 +0000 |
| Subject: | note 96224 deleted from book.dom by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166015@lists.php.net to get a copy of this message | ||
Note Submitter: mcgooogletz at gmail dot com
----
xml notes:
<tag one="one"/>
<tag two="two"/>
<tag three="three/>
-tags can be read as arrays (their text nodes) BUT
multiple attributes means accessing them one at a time.
i.e.:
<thing1 length="2" width="4" height="4/>
thing1["length"] //
thing1["width"] //
thing1["height"]//
-don't even think about this:
thing1["length"]["width"]["height"];
// you have to do them one at a time. -it's for your own good.
//something to look out for..
<thing1 length="2" width="4" height="4/>
<thing1 length="3" width="4" height="4/>
can't do this: thing1[0]["length"]; //so very wrong.
-however foreach looping might solve it.
->psuedo code below.
foreach ($thing1 as $a){
$a["length"] //
$a["width"] //
$a["height"]//
}
-----------------------------------------
last note: -analogy.
//exhibit a: inefficiency with tags..-good for text storage-
large chunks of raw data like news articles..
(char)$var="blue";
<var>blue</var>
//exhibit b: efficient attribute implementation
(good for data heavy filing (i.e.. like storing a multitude
of values (think like exporting images and such))
$var2=array($one,$two,$three,
$four=array($haha,
$what_now=array($huh, $oh, $oops)
)
);
<var2 one='' two='' three=''>
<four haha=''>
<what_now huh='' oh='' oops=''/>
</four>
</var2>
-be smart with your attributes and make psuedo structures
with them as opposed to riddling the doc with more text node tags than data :).