Wednesday, 13 April 2016

XML : XSLT - Print Child node names (Tree Structure / Folder Explorer Style)

Need expert help to get desired output using XSLT. Basically trying to find a way to do the tree structure or folder navigation. If the root node has child node, I would need to set type : object. and out put the child node names under properties:. The xml is dynamic and I will not know the node names since it comes from database.

XML

  <response>      <Node_A_1>          <Node_B_1>P</Node_B_1>          <Node_B_2>              <Node_C_1>B</Node_C_1>              <Node_C_2>B</Node_C_2>          </Node_B_2>          <Node_B_3>4110838</Node_B_3>                  </Node_A_1>      <Node_A_2>          <Node_B_6>Ok</Node_B_6>          <Node_B_7>              <Node_C_6>2016-04-13T08:57:23.552-05:00</Node_C_6>           </Node_B_7>          <Node_B_8>200</Node_B_8>      </Node_A_2>     

Expected Out Put

  response:      type: Object      properties:         Node_A_1:           type: Object           properties:              Node_B_1:               type: string              Node_B_2:               type: Object               properties:                  Node_C_1:                     type: string                  Node_C_2:                     type: string             Node_B_3:                type: string        Node_A_2:           type: object           properties:              Node_B_6                 type: String              Node_B_7                 type: object                   properties:                    Node_C_6                       type: String              Node_B_8                  type: String    

No comments:

Post a Comment