|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, February 04, 2013 6:46 AM
Points: 2,
Visits: 24
|
|
I need to generate XML results from a query and the node names need to be dynamically generated based on the results of that query. Does anyone know how I can produce xml similar to this? <root name> <product_somethingdynamicgoeshere> <recipes> <recipe_somethingdynamichere></recipe_somethingdynamichere> <recipe_somethingdynamichere></recipe_somethingdynamichere> </recipes> </root name>
Thanks in advance for your help!
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, May 02, 2013 1:20 PM
Points: 1,235,
Visits: 5,389
|
|
This sounds suspiciously like a homework assignment. The answer to this question is easily found with a little research. The fact that you didn't find it suggests that you didn't even bother to try.
Drew
J. Drew Allen Business Intelligence Analyst Philadelphia, PA
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, February 04, 2013 6:46 AM
Points: 2,
Visits: 24
|
|
Definitely not a homework assignment. I am new to this sort of thing and have managed to get the data in the following format using a XML Explicit: <PRODUCT Product_name=something> ....nested tree levels here </PRODUCT>
and I need to have it appear as <PRODUCT_something> -node name. If there is an easy solution or if you know somewhere I can check, please pass it along. Thanks!
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, May 02, 2013 1:20 PM
Points: 1,235,
Visits: 5,389
|
|
Depending on the complexity of your query, you could try FOR XML AUTO, ELEMENTS or FOR XML PATH('some value') instead of XML EXPLICIT.
Drew
J. Drew Allen Business Intelligence Analyst Philadelphia, PA
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, May 02, 2013 1:20 PM
Points: 1,235,
Visits: 5,389
|
|
You may also need to use dynamic SQL. It's really difficult to tell without DDL, sample data, and expected results to work with.
Drew
J. Drew Allen Business Intelligence Analyst Philadelphia, PA
|
|
|
|