seopower Posted July 5, 2007 Share Posted July 5, 2007 I have a XML which can have n number of nested categories and subcategories. The problem is node names are all same for each level. Now can any please tell how can I display names with relation between each? I mean display should be: Category 1 - Subcategory - More Subcategory Category 2 - Subcategory - More Subcategory and so on.... The XML I am having is something like this: <taxonomy> <form id=1 name=category1> <taxonomy> <form id=2 name=subcategory1> </taxonomy> <form id=3 name=category2> <form id=4 name=category3> </taxonomy> Link to comment https://forums.phpfreaks.com/topic/58532-xml-with-n-numbers-of-nested-categories/ Share on other sites More sharing options...
BillyBoB Posted July 5, 2007 Share Posted July 5, 2007 i dont know much about xml but from what you are saying wanting to have them linked could you do something like <taxonomy> <form id=1 name=category1> <taxonomy> <form id=1 name=subcategory1> <form id=1 name=subcategory2> <form id=1 name=subcategory3> <form id=1 name=subcategory4> </taxonomy> <form id=3 name=category2> <form id=4 name=category3> </taxonomy> like i said i dont know much so i hope this helps Link to comment https://forums.phpfreaks.com/topic/58532-xml-with-n-numbers-of-nested-categories/#findComment-290337 Share on other sites More sharing options...
seopower Posted July 5, 2007 Author Share Posted July 5, 2007 i dont know much about xml but from what you are saying wanting to have them linked could you do something like I want to know how will php loop (or any other method) will work to get data from xml in above mentioned format? Link to comment https://forums.phpfreaks.com/topic/58532-xml-with-n-numbers-of-nested-categories/#findComment-290478 Share on other sites More sharing options...
seopower Posted July 9, 2007 Author Share Posted July 9, 2007 Any help will be very much appriciated. Link to comment https://forums.phpfreaks.com/topic/58532-xml-with-n-numbers-of-nested-categories/#findComment-293115 Share on other sites More sharing options...
ToonMariner Posted July 9, 2007 Share Posted July 9, 2007 First off you should NOT use singleton tags in xml - each tag should be opened AND closed. xsl(t) is how the information is 'looped' and formated for display on a page. now out of interest are these forms going to be html forms? if so you should NOT nest html forms. If that is indeed what you intended I suggest you alter you approach. Link to comment https://forums.phpfreaks.com/topic/58532-xml-with-n-numbers-of-nested-categories/#findComment-293122 Share on other sites More sharing options...
harristweed Posted July 9, 2007 Share Posted July 9, 2007 ToonMariner is correct the xml should look like this: <taxonomy> <form id="1" name="category1"> <taxonomy> <form id="2" name="subcategory1"> </form> </taxonomy> </form> <form id="3" name="category2"> </form> <form id="4" name="category3"> </form> </taxonomy> Link to comment https://forums.phpfreaks.com/topic/58532-xml-with-n-numbers-of-nested-categories/#findComment-293131 Share on other sites More sharing options...
seopower Posted July 9, 2007 Author Share Posted July 9, 2007 This is the actual XML: <taxonomy> <form id="96451" name="Cars"> <taxonomy> <form id="96477" name="Auto Parts and Accessories"></form> <form id="96621" name="Automotive Security Systems"></form> <form id="96478" name="Motorcycle Parts and Accessories"></form> <form id="96456" name="New Cars"> <form id="96457" name="Used Cars"></form> </taxonomy> </form> <form id="2010" name="Clothing and Accessories"> <taxonomy> <form id="31515" name="Clothing"></form> <form id="68185" name="Luggage"></form> <form id="96602" name="Shoes"></form> </taxonomy> </form> </taxonomy> and so one...by this you will have idea about categories and subcategories. Also I cant modify XML as its being provided by REST method from someone else. Link to comment https://forums.phpfreaks.com/topic/58532-xml-with-n-numbers-of-nested-categories/#findComment-293189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.