Fiddlercore change responce between tags of dynamic content

3 posts, 1 answers
  1. asia
    asia avatar
    4 posts
    Member since:
    Sep 2014

    Posted 01 Feb 2015 Link to this post

    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. asia
    asia avatar
    4 posts
    Member since:
    Sep 2014

    Posted 01 Feb 2015 Link to this post

    also to note its an xml file that i want to change its content which is returned by the server

    cheers
  3. Answer
    Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 02 Feb 2015 Link to this post

    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.

     
Back to Top