E
E
Hi everyone,
I'm new to XML and I'm just wondering if someone could point me to some
tutorials on how to generate an XML file using PHP? I've been Googling for
a few hours and I've yet to find anything that matches what I'm trying to
do. Maybe I'm not using the correct terms???
What I'm trying to do is to use data from the MySQL table below to generate
an XML file which I will then use to display that info as a hierarchy.
+----+-----------+------------------+
| id | parent_id | name |
+----+-----------+------------------+
| 1 | NULL | about us |
| 2 | NULL | products |
| 3 | NULL | contact us |
| 4 | 2 | product1 |
| 5 | 2 | product2 |
| 6 | 2 | product3 |
| 7 | 4 | category1.1 |
| 8 | 4 | category1.2 |
| 9 | 4 | category1.3 |
| 10 | 5 | category2.1 |
| 11 | 5 | category2.2 |
| 12 | 6 | category3.1 |
| 13 | 7 | subcategory1.1.1 |
| 14 | 7 | subcategory1.1.2 |
+----+-----------+------------------+
Expected result:
- About Us
- Products
- Product 1
- Category 1.1
- SubCategory 1.1.1
- SubCategory 1.1.2
- Category 1.2
- Category 1.3
- Product 2
- Category 2.1
- Category 2.2
- Product 3
- Category 3.1
- Contact Us
First of all, how do I arrange the above data into an XML file and then, how
do I read the data from the file and display it like the list above?
TIA
Eric
I'm new to XML and I'm just wondering if someone could point me to some
tutorials on how to generate an XML file using PHP? I've been Googling for
a few hours and I've yet to find anything that matches what I'm trying to
do. Maybe I'm not using the correct terms???
What I'm trying to do is to use data from the MySQL table below to generate
an XML file which I will then use to display that info as a hierarchy.
+----+-----------+------------------+
| id | parent_id | name |
+----+-----------+------------------+
| 1 | NULL | about us |
| 2 | NULL | products |
| 3 | NULL | contact us |
| 4 | 2 | product1 |
| 5 | 2 | product2 |
| 6 | 2 | product3 |
| 7 | 4 | category1.1 |
| 8 | 4 | category1.2 |
| 9 | 4 | category1.3 |
| 10 | 5 | category2.1 |
| 11 | 5 | category2.2 |
| 12 | 6 | category3.1 |
| 13 | 7 | subcategory1.1.1 |
| 14 | 7 | subcategory1.1.2 |
+----+-----------+------------------+
Expected result:
- About Us
- Products
- Product 1
- Category 1.1
- SubCategory 1.1.1
- SubCategory 1.1.2
- Category 1.2
- Category 1.3
- Product 2
- Category 2.1
- Category 2.2
- Product 3
- Category 3.1
- Contact Us
First of all, how do I arrange the above data into an XML file and then, how
do I read the data from the file and display it like the list above?
TIA
Eric