user787951
user787951

Reputation:

Display data from XML in a SSRS tooltip

I am creating a SSRS report. I need to display text in a tooltip(The data is in XML format) . Below is my sample xml.

<warnings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <row>
        <linetext>This is Sugar.</linetext>
    </row>
    <row>
        <linetext>This is coffee.</linetext>
    </row>
</warnings>

I need the data inside the linetext node in bulleted format in the tooltip.Below is the format I would want in my tooltip.

.This is Sugar

.This is Coffee

Please Help!!

Thanks

Upvotes: 0

Views: 1997

Answers (1)

Jamie F
Jamie F

Reputation: 23789

The nice answer would be to write a custom assembly (.dll) and deploy that to your reporting server. In the custom assembly you can use the .NET xml parsing classes and iterate through your XML to get what you want.

But a hack answer is below. Embed this code in the report (Report menu -> Report Properties -> Code & paste to the text pane.)

Public Function ParseMyXML(ByVal s As String) As String
    Dim parts() AS String = Split(s, "<linetext>")
    Dim strBuilder As New System.Text.StringBuilder()
    For i As Integer = 1 To parts.length - 1
        strBuilder.Append(". ")
        strBuilder.Append(Left(parts(i) , Instr(parts(i),"<") -1) & ControlChars.NewLine )
    Next i
    Return strBuilder.ToString()
End Function

Then call this from the body of the report with "=Code.ParseMyXML(stringFromWebService)"

The code above splits the xml and takes the text from the tag to the next "<" Not robust, but easy to implement and deploy. I think you can handle special characters by then treating the placeholder as html.

(First Visual Basic (> 1 line) I've written in months, maybe years.)

Upvotes: 4

Related Questions