Answered by:
Report with XML Data

Question
-
hi
Currently, I am trying to render XML data in the report in XML format. Unfortunately I can not find a way to render the data correctly formatted cleanly. Is there a way for that? Any kind of help is appreciated
at the Moment I use ,replace(cast([xmldata1] as varchar(max)),'><',char(13) + char(10))
but this is more or less ...
Klaus
- Edited by Klaus Bilger Tuesday, October 15, 2019 11:16 AM
Answers
-
- Proposed as answer by Lukas DreiKleinMicrosoft contingent staff Wednesday, October 16, 2019 2:57 AM
- Marked as answer by Klaus Bilger Thursday, October 17, 2019 10:47 AM
All replies
-
-
hi Olaf,
thx for the fast answer.
the data is inside a SQL Tbl with 2 fields.
the first field has the data as nvarchar(max), the seond field data type is XML and the Data is also XML.
if I run the query the XML Format is not visible on the Report.
the Datasource is not like https://docs.microsoft.com/en-us/sql/reporting-services/report-data/xml-connection-type-ssrs?view=sql-server-ver15.
the datasource is SQL DB,
Klaus
- Edited by Klaus Bilger Tuesday, October 15, 2019 12:23 PM
-
Then you can use SQL xQuery to get the data in a structured format, example
CREATE TABLE #TEST(xmldata xml); GO INSERT INTO #TEST (xmldata) VALUES( N'<Config> <Process> <UseCase Name="Name of UseCase" Action="run" /> </Process> <Process> <UseCase Name="UseCase 2" Action="wait" /> </Process> </Config>'); GO SELECT node.row.value('(.//@Name)[1]', 'varchar(100)') as Name, node.row.value('(.//@Action)[1]', 'varchar(100)') as Action FROM #TEST AS T CROSS APPLY T.xmldata.nodes(N'//Config/Process/UseCase') AS node(row) GO DROP TABLE #TEST;
Olaf Helper
[ Blog] [ Xing] [ MVP] -
Hello Olal,
I'm really thankful for your help!
The translation of the XML into SQL is not that the problem, the problem here is that I have to render the XML structure as well as picture 2 in the report.
If I do that with the XML Query I have the data then in columns but I lose the XML format and that is exactly what should be displayed.Klaus
Klaus
-
- Proposed as answer by Lukas DreiKleinMicrosoft contingent staff Wednesday, October 16, 2019 2:57 AM
- Marked as answer by Klaus Bilger Thursday, October 17, 2019 10:47 AM
-
-
Thanks for the discussion and knowledge sharing.
MSDN Community Support Please remember to click Mark as Answer; the responses that resolved your issue, and to click Unmark as Answer if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.