Converting DataSet into XML with nested elements

后端 未结 3 1219
悲&欢浪女
悲&欢浪女 2021-01-27 03:03

I am writing a WebService that is supposed to convert DataSet into XML. My DataSet is actually list of hotels with categories. Each hotel can belong to one or more categories. I

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-27 03:43

    1) Does it actually matter? Is one structure better then another one?

    Yes if you added the category ID to the cateogry output then its easy to reason about what Id goes with which name

    
        1
        Hotel
    
    
        2
        Resort
    
    
        3
        Golf & Spa
    
    

    This on the other hand is hard to reason which Id goes with which name because the associations are positional.

    
        1
        Hotel
        2
        Resort
        3
        Golf & Spa
    
    

    2) Is it possible to make relation between two tables in DataSet so I get output like it is in second (desired) XML example.

    There's a number of approaches you take to make this happen, (linq to dataset, XSLT, etc) but I can't think of a direct way off hand.

提交回复
热议问题