Jump to content

XML with n numbers of nested categories


seopower

Recommended Posts

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

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

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.

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>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.