This is a migrated thread and some comments may be shown as answers.

Fiddlercore change responce between tags of dynamic content

2 Answers 196 Views
Windows
This is a migrated thread and some comments may be shown as answers.
asia
Top achievements
Rank 1
asia asked on 01 Feb 2015, 10:32 PM
Hi there

I want in c# to change the responce of the server using fiddlercore, I know i can do it like this

oS.utilReplaceInResponse("Microsoft", "Bayden");

BUT what happens if i want to change some dynamic text data between tags to something that is always the same like

oS.utilReplaceInResponse("<version>this can be 5,6,7,8 and change every month</version>", "<version>5</version>");

I want to be able to replace the text or number between some tags that might change over time to always return 5

i have tried with .? with * with .* and they all fail how do i do this ?

cheers

2 Answers, 1 is accepted

Sort by
0
asia
Top achievements
Rank 1
answered on 01 Feb 2015, 11:07 PM
also to note its an xml file that i want to change its content which is returned by the server

cheers
0
Accepted
Eric Lawrence
Telerik team
answered on 02 Feb 2015, 07:41 PM
To use a regular expression rather than a plain string, you must call the appropriate method:

oSession.utilReplaceRegexInResponse(string sSearchForRegEx, string sReplaceWithExpression);

        /// <param name="sSearchForRegEx">The regular expression used to search the body. Specify RegEx Options via leading Inline Flags, e.g. (?im) for case-Insensitive Multi-line.</param>
        /// <param name="sReplaceWithExpression">The text or expression used to replace</param>
        /// <returns>TRUE if replacements occured</returns>
        [CodeDescription("Perform a regex-based replacement on the response body. Specify RegEx Options via leading Inline Flags, e.g. (?im) for case-Insensitive Multi-line. Updates Content-Length header. Note, you should call utilDecodeResponse first!  Returns TRUE if replacements occur.")]
   


Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Windows
Asked by
asia
Top achievements
Rank 1
Answers by
asia
Top achievements
Rank 1
Eric Lawrence
Telerik team
Share this question
or