Hi Udara, According to the W3C XML 1.0 Specification <https://www.w3.org/TR/REC-xml/#sec-common-syn> you *cannot* have spaces on the XML element name. To be precise;
[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] [5] Name ::= NameStartChar (NameChar)* However; As I feel when there are XML element names with *spaces* the second word is treated as an *attribute* to the XML element. eg. <Employee Id> would be treated as; <Employee Id=""> Therefore; Can you try; "<property name="test" expression="*//Employee[@Id]*'"/>" which should do the trick. Thanks, ~Rasika On Mon, Mar 7, 2016 at 2:55 PM, Udara Liyanage <[email protected]> wrote: > Hi, > > It gives me following error. > > Below is my synapse configs. > > ##call external api > <call> > <endpoint> > <http method="POST" uri-template=" > https://api.peoplehr.net/Query"/> > </endpoint> > </call> > > #iterate thru results > <iterate id="iter1" expression="//Result"> > <target> > <sequence> > <log level="custom"> > <property name="test" expression="*json-eval($.Employee > Id)*"/> > </log> > > Sample API call output > > { > > > "Message": "The requested processed successfully.", > "Result": [ > { > "Department": "HUMAN RESOURCES AND ADMINISTRATION", > "Employee Id": "456", > > }, > { > "Department": "MARKETING", > "Employee Id": "123", > }, > > > JsonUtil #toJsonStream. Could not create input stream from XML element > [<Result><Employee Id>123</Employee > Id><Department>ENGINEERING</Department></Result>]. Error>>> Could not > convert OMElement to JSON. Invalid XML payload. > > On Mon, Mar 7, 2016 at 2:42 PM, Keerthika Mahendralingam < > [email protected]> wrote: > >> Hi Udara, >> Since you are getting JSON response, I think you can use json-eval to get >> the value form response like, >> >> <property name="id" expression="json-eval($.Employee Id)"/> >> >> >> Thanks, >> >> On Mon, Mar 7, 2016 at 2:31 PM, Udara Liyanage <[email protected]> wrote: >> >>> Hi, >>> >>> We have an call mediator which calls and external API. API response is >>> json. Json properties has spaces in names. >>> { >>> "Department": "ENGINEERING", >>> "Employee Id": "LK", >>> "First Name": "Udara", >>> >>> } >>> >>> ESB converts this to xml, those xml element names also have space in >>> element name. >>> >>> On Mon, Mar 7, 2016 at 2:05 PM, Udara Liyanage <[email protected]> wrote: >>> >>>> Hi, >>>> >>>> Below is the log mediator output. Even the converted xml tag has space >>>> in its name. >>>> >>>> [2016-03-07 14:00:36,587] INFO - LogMediator To: >>>> http://www.w3.org/2005/08/addressing/anonymous, WSAction: , >>>> SOAPAction: , MessageID: urn:uuid:2b6e4e6d-9180-4083-b06b-d12c08c5178e, >>>> Direction: request, Envelope: <?xml version='1.0' >>>> encoding='utf-8'?><soapenv:Envelope xmlns:soapenv=" >>>> http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><Result>*<Employee >>>> Id>*123*</Employee Id>*<First Name>udara</First Name><Last >>>> Name>liyanage</Last Name></Result></soapenv:Body></soapenv:Envelope> >>>> >>>> On Mon, Mar 7, 2016 at 12:06 PM, Udara Liyanage <[email protected]> wrote: >>>> >>>>> Hi Thusitha, >>>>> >>>>> I already tried that, but negative. >>>>> >>>>> On Mon, Mar 7, 2016 at 11:59 AM, Thusitha Thilina Dayaratne < >>>>> [email protected]> wrote: >>>>> >>>>>> Hi Udara, >>>>>> >>>>>> Did you tried replace the space with "_x0020_"? according to the [1] >>>>>> it seems work for spaces >>>>>> [1] - >>>>>> *http://users.jackrabbit.apache.narkive.com/r9aFPfiI/xpath-query-with-space-in-node-name >>>>>> <http://users.jackrabbit.apache.narkive.com/r9aFPfiI/xpath-query-with-space-in-node-name>* >>>>>> >>>>>> Thanks >>>>>> On Mon, Mar 7, 2016 at 11:43 AM, Udara Liyanage <[email protected]> >>>>>> wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> I am trying to fetch an property value from a json payload similar >>>>>>> to below. >>>>>>> { >>>>>>> "Department": "ABC", >>>>>>> "Employee Id": "123", >>>>>>> "Work Email": "[email protected]" >>>>>>> }, >>>>>>> >>>>>>> I could extract Department value by below xpath expression. >>>>>>> >>>>>>> <property name="test" expression="//Department'"/> >>>>>>> >>>>>>> However when I found difficulties when the property name contains an >>>>>>> space in middle. I tried few options which were not successful. What is >>>>>>> the correct way to escape space character. >>>>>>> >>>>>>> <property name="test" expression="//'Employee${nbsp}Id'"/> >>>>>>> >>>>>>> <property name="test" expression="//'Employee Id'"/> >>>>>>> >>>>>>> -- >>>>>>> >>>>>>> Udara Liyanage >>>>>>> Software Engineer >>>>>>> WSO2, Inc.: http://wso2.com >>>>>>> lean. enterprise. middleware >>>>>>> >>>>>>> web: http://udaraliyanage.wordpress.com >>>>>>> phone: +94 71 443 6897 >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Dev mailing list >>>>>>> [email protected] >>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Thusitha Dayaratne >>>>>> Software Engineer >>>>>> WSO2 Inc. - lean . enterprise . middleware | wso2.com >>>>>> >>>>>> Mobile +94712756809 >>>>>> Blog alokayasoya.blogspot.com >>>>>> About http://about.me/thusithathilina >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> >>>>> Udara Liyanage >>>>> Software Engineer >>>>> WSO2, Inc.: http://wso2.com >>>>> lean. enterprise. middleware >>>>> >>>>> web: http://udaraliyanage.wordpress.com >>>>> phone: +94 71 443 6897 >>>>> >>>> >>>> >>>> >>>> -- >>>> >>>> Udara Liyanage >>>> Software Engineer >>>> WSO2, Inc.: http://wso2.com >>>> lean. enterprise. middleware >>>> >>>> web: http://udaraliyanage.wordpress.com >>>> phone: +94 71 443 6897 >>>> >>> >>> >>> >>> -- >>> >>> Udara Liyanage >>> Software Engineer >>> WSO2, Inc.: http://wso2.com >>> lean. enterprise. middleware >>> >>> web: http://udaraliyanage.wordpress.com >>> phone: +94 71 443 6897 >>> >>> _______________________________________________ >>> Dev mailing list >>> [email protected] >>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>> >>> >> >> >> -- >> <[email protected]> >> Keerthika Mahendralingam >> Associate Software Engineer >> Mobile :+94 (0) 776 121144 >> [email protected] >> WSO2, Inc. >> lean . enterprise . middleware >> > > > > -- > > Udara Liyanage > Software Engineer > WSO2, Inc.: http://wso2.com > lean. enterprise. middleware > > web: http://udaraliyanage.wordpress.com > phone: +94 71 443 6897 > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- With Regards, *Rasika Perera* Software Engineer M: +94 71 680 9060 E: [email protected] LinkedIn: http://lk.linkedin.com/in/rasika90 WSO2 Inc. www.wso2.com lean.enterprise.middleware
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
