PHP Classes

How to get Attributes?

Recommend this page to a friend!

      Generic XML parser class  >  All threads  >  How to get Attributes?  >  (Un) Subscribe thread alerts  
Subject:How to get Attributes?
Summary:It isn't obvious on how to get attributes.
Messages:13
Author:steven shiflett
Date:2004-12-21 20:40:23
Update:2009-05-28 09:00:49
 
  1 - 10   11 - 13  

  11. Re: How to get Attributes?   Reply   Report abuse  
Picture of posin posin - 2009-05-28 05:52:13 - In reply to message 9 from Manuel Lemos
my xml looks like this ,
<?xml version="1.0"?>
<course id="c761121468629658443130857722312" name="Principles of Adaptive Learning" title="">

<objective id="o726349650403959701257411043342" name="Principles of Adaptive Learning" user_type="">

<concept id="p735026920794384385669561538445" name="Changing the Interface of Education" prerequisites="" user_type="" xposition="95" yposition="111">

<assignableunit contenttype="text/html" description="" id="a783581015094191905629628924302" mediatype="" name="t1_1introduction.htm" source="C:\4DL\NishCourse\t1\Introduction\t1_1introduction.htm">
</assignableunit>

<assignableunit contenttype="" description="" id="a816516252757810437951705158654" mediatype="" name="http://192.182.133.34/NishCourse/CustomFlash/SCFFlash/C1/SC1/Page2-3_SCFFLash.swf" source="http://192.182.133.34/NishCourse/CustomFlash/SCFFlash/C1/SC1/Page2-3_SCFFLash.swf">
</assignableunit>

<assignableunit contenttype="" description="" id="a698166761403766055298218809466" mediatype="" name="http://192.182.133.34/NishCourse/CustomFlash/TDFlash/C1/SC4/C1SC4TDchanging.swf" source="http://192.182.133.34/NishCourse/CustomFlash/TDFlash/C1/SC4/C1SC4TDchanging.swf">
</assignableunit>

<learningstyle style="Apprenticeship">

<learningstylegroup id="g275624393041083428348430089937" name="page 1" qualifier="Step">

<learningstyletag aureference="a783581015094191905629628924302" id="t531476628350223407706619043555" name="t1_1introduction.htm" qualifier="Description">
</learningstyletag>

<learningstyletag aureference="" id="t519441769310645460997873523580" name="Untitled" qualifier="Page Break (with Layout 1-1)">
</learningstyletag>

</learningstylegroup>

</learningstyle>

<concept id="p008842736725115071914023722694" name="Reinventing Pedagogy" prerequisites="" user_type="" xposition="91" yposition="70">
<assignableunit contenttype="text/html" description="" id="a912210430778845074003424253633" mediatype="" name="t1_2reinventingPedagogy.htm" source="C:\4DL\NishCourse\t1\St1\t1_2reinventingPedagogy.htm">
</assignableunit>

<assignableunit contenttype="text/html" description="" id="a286978282610530540514175112182" mediatype="" name="t1_3reinventingPedagogy.html" source="C:\4DL\NishCourse\t1\St1\t1_3reinventingPedagogy.html">
</assignableunit>

<learningstyle style="Apprenticeship">

<learningstylegroup id="g789353719334634380201010779594" name="TD FLASH" qualifier="Step">

<learningstyletag aureference="a271286002238102113845194687485" id="t522468679837713152450848139774" name="http://192.182.133.34/NishCourse/CustomFlash/TDFlash/C1/SC1/C1SC1TDchanging.swf" qualifier="Description">
</learningstyletag>

<learningstyletag aureference="" id="t303820907443472246821089263697" name="Untitled" qualifier="Page Break (with Layout 1-1)">
</learningstyletag>

</learningstylegroup>


</learningstyle>

</concept>

</concept>
</objective>
</course>




through your class i am getting [x,x,x]nodename[x,x,x] this type of parsed structure. But, i want each attribute value of every node

  12. Re: How to get Attributes?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-05-28 07:43:14 - In reply to message 10 from posin
If you look at the test_xml_parser.php example script, you can see how the DumpStructure acesses the parsed document structure array.

There is a single array with entries that specify the path of each tag or data element. If the element is a tag, the structure entry for that element is an array. The attributes are in the Attributes array.

Note that if you use the simple XML parse mode, attributes are ignored.

  13. Re: How to get Attributes?   Reply   Report abuse  
Picture of posin posin - 2009-05-28 09:00:49 - In reply to message 12 from Manuel Lemos
thanks alot for your help . i am able to fetch all attributes of every node in the form of associative array . like ;

[2,22,115]<course>[2,25,118]array(3) {
["id"]=>
string(31) "c761121468629658443130857722312"
["name"]=>
string(31) "Principles of Adaptive Learning"
["title"]=>
string(0) ""
}
[4,30,224]<objective>[4,32,226]array(3) {
["id"]=>
string(31) "c761121468629658443130857722312"
["name"]=>
string(31) "Principles of Adaptive Learning"
["title"]=>
string(0) ""
}
[6,63,382]<concept>[6,65,384]array(3) {
["id"]=>
string(31) "c761121468629658443130857722312"
["name"]=>
string(31) "Principles of Adaptive Learning"
["title"]=>
string(0) ""
}
[8,68,589]<assignableunit>[9,4,595]array(3) {
["id"]=>
string(31) "c761121468629658443130857722312"
["name"]=>
string(31) "Principles of Adaptive Learning"
["title"]=>
string(0) ""
}
</assignableunit>........... and so on ......

 
  1 - 10   11 - 13