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> Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.