Save snapshot as XML via C# API

Class library usage, coding and language questions.
bprommeg
Posts: 2
Joined: Tue Aug 27, 2013 1:25 pm

Save snapshot as XML via C# API

Post by bprommeg » Mon Sep 09, 2013 12:16 pm

Hi,

in Ranorex Spy it is possible to save an element an all its childs (including all attributes) as snapshotfile in XML Format. Can you do the same using the C# API?

thx,
Bernhard

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

Re: Save snapshot as XML via C# API

Post by Support Team » Mon Sep 09, 2013 6:10 pm

Hello Bernhard,

There is a method named Snapshot() which can be used in order to create a Ranorex Snapshot file using API.
For example:
public static void Snapshot(
	Element target
)
Please take a look in our "Online API Documentation".

Regards,
Bernhard
.
Image

bprommeg
Posts: 2
Joined: Tue Aug 27, 2013 1:25 pm

Re: Save snapshot as XML via C# API

Post by bprommeg » Wed Sep 11, 2013 3:09 pm

thx for your reply. that helped.

but i have another question:
whenever i save a snapshot (independent if I use ranorex spy or the api method SerializeXml()), the XML gets pretty printed like that:

Code: Select all

        <attribute
        name="windowtext"
        type="System.String">
          Calculator
        </Attribute>
as a result of this, whenever i access the values of the XML they contain leading and trailing whitespaces because other programms interpret the value as something like:

Code: Select all

<tag>\n
\t\tvalue\n
</tag>
is it possible to save the snapshot without the extra whitespaces or do I have to get rid of them myself?

thanks,
bernhard

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

Re: Save snapshot as XML via C# API

Post by Support Team » Thu Sep 12, 2013 4:56 pm

Hello Bernhard,

Unfortunately this is not possible out of the box.
I am afraid that you have to change it in the already created snapshot.

Regards,
Bernhard
.
Image