XML fragment within report breaks it

Ask general questions here.
User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

XML fragment within report breaks it

Post by sdaly » Fri Aug 19, 2011 3:13 pm

Hi

I have the following validation in one of my tests -

Ranorex.Validate.IsTrue(response.Contains(@"<clientid>1407</clientid>"), "Validating response contains client ID 1407");

However, when the report is loaded I get the error message below...... Would it be possible to wrap the data in a CDATA tag by default so this does not break?

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

End tag 'name' does not match the start tag 'message'. Error processing resource 'file:///R:/Logs/DevTests/APITest/19-08-20...

<result created="2011-08-19T14:59:49+01:00" host="**************" status="OK"><items><client><n...

Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: XML fragment within report breaks it

Post by Support Team » Mon Aug 22, 2011 12:33 pm

Hey Scott,

Where/How are you logging the value ?
The one code line you posted can't possibly log anything with an HTML tag in it ...
Could you also post a larger part of the XML report ?

Michael
Ranorex Team
.
Image

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: XML fragment within report breaks it

Post by sdaly » Mon Aug 22, 2011 2:07 pm

Hi Michael

Ah it may not be that line, there is an http request created and the response is xml which is logged to the report. Here is the full log below...

Would Report.LogData or Report.LogHTML be better?


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="file:///R:\logs\RanorexReport.xsl"?>
<log title="Ranorex Test Report" rxversion="3.0.5.13548" runtimeversion="4.0.30319.235">
<message time="2011/08/19 17:07:09.030" level="INFO" category="Username: " style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\TestRun.cs" codeline="209">
<![CDATA[tony.rafferty]]><br/>
</message>
<message time="2011/08/19 17:07:09.032" level="INFO" category="Test Build: " style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\TestRun.cs" codeline="214">
<![CDATA[1.0.4248.29009]]><br/>
</message>
<message time="2011/08/19 17:07:09.034" level="INFO" category="Test Name" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\TestRun.cs" codeline="215">
<![CDATA[DevTests::APITest]]><br/>
</message>
<message time="2011/08/19 17:07:09.036" level="INFO" category="Browser" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\TestRun.cs" codeline="216">
<![CDATA[iexplore.exe]]><br/>
</message>
<message time="2011/08/19 17:07:09.038" level="INFO" category="Selected Agent 1" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\TestRun.cs" codeline="217">
<![CDATA[Agent_8_9 svn.24208]]><br/>
</message>
<message time="2011/08/19 17:07:09.041" level="INFO" category="Selected Agent 2" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\TestRun.cs" codeline="218">
<![CDATA[Agent_8_7 svn.22279]]><br/>
</message>
<message time="2011/08/19 17:07:09.050" level="INFO" category="SystemSummary" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\TestRun.cs" codeline="219">
<![CDATA[Host: UKDUMXQADQTRAF]]><br/>
<![CDATA[Ranorex version: 3.0.5.13548]]><br/>
<![CDATA[OS version: Windows 7 Service Pack 1 64bit]]><br/>
<![CDATA[OS default locale: en-US]]><br/>
<![CDATA[.NET Runtime version: 4.0.30319.235]]><br/>
<![CDATA[Number of logical CPUs: 3]]><br/>
<![CDATA[Number of displays: 2]]><br/>
<![CDATA[Screen dimension: 3840x1080]]><br/>
<![CDATA[Memory: 23% load, phy 12414mb free/16127mb total, virt 1766mb free/2047mb total.]]><br/>
</message>
<message time="2011/08/19 17:07:09.536" level="INFO" category="Available drives" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\TestRun.cs" codeline="222">
<![CDATA[Name - C:\ Format - NTFS Type - Fixed, Name - D:\ Format - NTFS Type - Fixed, Name - E:\ Format - NTFS Type - Network, Name - R:\ Format - NTFS Type - Network, Name - S:\ Format - NTFS Type - Network, Name - Z:\ Format - NTFS Type - Network]]><br/>
</message>
<message time="2011/08/19 17:07:09.541" level="INFO" category="TestRun::StartRanorexReport" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\CommonGFI.cs" codeline="52">
<![CDATA[Current report is 19-08-2011-05-07-08_tag_DevTests_APITest.xml]]><br/>
</message>
<message time="2011/08/19 17:07:09.886" level="INFO" category="Screenshot" style="">
<a href="19-08-2011-05-07-08_tag_DevTests_APITest.xml_1_rxlog.jpg"><img src="19-08-2011-05-07-08_tag_DevTests_APITest.xml_1_rxlog_thumb.jpg" alt="Screenshot"/></a>
</message>
<message time="2011/08/19 17:07:09.959" level="INFO" category="TestDataSerialiser::DeserialiseFromXML" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\CommonGFI.cs" codeline="52">
<![CDATA[Reading and deserialising test data from DevTests_APITest.xml]]><br/>
</message>
<message time="2011/08/19 17:07:10.351" level="INFO" category="NetworkGFI::GetWebPageSourceText" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\CommonGFI.cs" codeline="52">
<![CDATA[Creating a web request for http://hs-dev.hound-dog.co.uk/api?apike ... st_clients&&]]><br/>
</message>
<message time="2011/08/19 17:07:10.759" level="INFO" category="NetworkGFI::APIRequest" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\CommonGFI.cs" codeline="52">
<![CDATA[Response is <?xml version="1.0" encoding="ISO-8859-1"?>
<result created="2011-08-19T17:06:51+01:00" host="hs-dev.hound-dog.co.uk" status="OK"><items><client><name><![CDATA[EventLog]]></name><clientid>1407</clientid><view_dashboard>0</view_dashboard><view_wkstsn_assets>0</view_wkstsn_assets><dashboard_username/><timezone></timezone><creation_date>2011-07-14</creation_date><device_count>1</device_count><server_count>1</server_count><workstation_count>0</workstation_count></client><client><name><![CDATA[MenusTest]]></name><clientid>1414</clientid><view_dashboard>0</view_dashboard><view_wkstsn_assets>0</view_wkstsn_assets><dashboard_username/><timezone/><creation_date>2011-08-10</creation_date><device_count>1</device_count><server_count>0</server_count><workstation_count>1</workstation_count></client><client><name><![CDATA[SomeClient]]></name><clientid>1415</clientid><view_dashboard>0</view_dashboard><view_wkstsn_assets>0</view_wkstsn_assets><dashboard_username/><timezone></timezone><creation_date/><device_count>0</device_count><server_count>0</server_count><workstation_count>0</workstation_count></client><client><name><![CDATA[SomeClient2]]></name><clientid>1416</clientid><view_dashboard>0</view_dashboard><view_wkstsn_assets>0</view_wkstsn_assets><dashboard_username/><timezone></timezone><creation_date/><device_count>0</device_count><server_count>0</server_count><workstation_count>0</workstation_count></client></items></result>
]]><br/>
</message>
<message time="2011/08/19 17:07:10.761" level="SUCCESS" category="Validation" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\TestCases\DevTests.cs" codeline="96">
<![CDATA[Validating response 1407]]><br/>
</message>
<message time="2011/08/19 17:07:10.763" level="SUCCESS" category="User" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\TestCases\DevTests.cs" codeline="96">
<![CDATA[Test Passed]]><br/>
</message>
<message time="2011/08/19 17:07:10.766" level="INFO" category="DevTests::TestTearDown" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\CommonGFI.cs" codeline="52">
<![CDATA[Running test cleanup.]]><br/>
</message>
<message time="2011/08/19 17:07:11.044" level="INFO" category="Screenshot" style="">
<a href="19-08-2011-05-07-08_tag_DevTests_APITest.xml_2_rxlog.jpg"><img src="19-08-2011-05-07-08_tag_DevTests_APITest.xml_2_rxlog_thumb.jpg" alt="Screenshot"/></a>
</message>
<message time="2011/08/19 17:07:11.116" level="INFO" category="TestRun::SetEndOfTest" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\CommonGFI.cs" codeline="52">
<![CDATA[Test Finished.]]><br/>
</message>
<message time="2011/08/19 17:07:11.118" level="INFO" category="TestRun::StopRanorexReport" style="" codefile="c:\Users\tony.rafferty\Desktop\AutomationSVN\GFI.Automation\GFI.Automation\CommonGFI.cs" codeline="52">
<![CDATA[Saving Ranorex report.]]><br/>
</message>
</log>

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: XML fragment within report breaks it

Post by Support Team » Mon Aug 22, 2011 2:34 pm

Scott,
This is a special case in XML: you cannot nest CDATA sections within CDATA sections :?
You can either do a "Replace("]]>", "whatever") on your string or use loghtml and encode your string with HttpUtility.EncodeHtml()

Michael
.
Image

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: XML fragment within report breaks it

Post by sdaly » Mon Aug 22, 2011 2:49 pm

Hi Michael

Ahhhh I see! Ok thanks for the info, I have went with your second suggestion :D

Thanks
Scott