webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Escape Content only between XML Tags

    Posted Fri February 21, 2014 10:41 AM

    Hello Forum-Member,

    we are getting some XML-String via FTP-Polling, unfortunately the source sytsem doesnt escaping the special character like [<, >, ', ", &].

    Here is the XML-String:

    <?xml version="1.0" encoding="utf-8"?> 20120221 Ms Ms This is an Example & Escape "CHAR"

    We needto escape only the Content between the XML-Tags. For example (see Attachment)

    I am using the build-in-service of SAG → HTML encode. But the whole String will be encoded. (see Attachment)

    Is there any solution for that?

    Best Regards
    2014-02-21 15_50_12-_new  3 - Notepad++.png


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 2.  RE: Escape Content only between XML Tags

    Posted Fri February 21, 2014 11:04 AM

    Which service you used the HTML encoding?

    If not you may have to manually use string:replace service to remove those & to & from the XML data.

    HTH,
    RMG


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 3.  RE: Escape Content only between XML Tags

    Posted Fri February 21, 2014 11:11 AM

    This Service “pub.string:HTMLEncode”, which I am using. But the whole XML-String is going to escaped.

    If I am using the Srevice “string:replace” then I thinnk I will get the same result. Meaning: The String with > < will be escaped too.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: Escape Content only between XML Tags

    Posted Fri February 21, 2014 12:21 PM

    You may consider the option of fixing it in the originating system, where the garbage are produced.

    if not, xml or encoding utilities will not work.
    I guess you have to write some java code to scan through the document to only encode the content, not the xml tags.
    It will be painful. keep in mind to deal with attributes and namespaces.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 5.  RE: Escape Content only between XML Tags

    Posted Fri February 21, 2014 01:14 PM

    No replace only what you wanted and aware of…spl chars like &," etc…

    Again its better they come correctly from the source systems other wise its a pain to deal all those spl chars in the XML parsing.

    HTH,
    RMG


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 6.  RE: Escape Content only between XML Tags

    Posted Tue February 25, 2014 10:35 AM

    No way.

    For your XML example:

    <?xml version="1.0" encoding="utf-8"?> 20120221 Ms Ms This is an Example & Escape "CHAR"

    You expect to escape the ’ " ’ inside HeaderText, but how the program can know the ‘<’ of HeaderText is not an escape char inside QuoteProperties, you can’t define which to escape and which not, so program don’t know what to do.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods