I think utils.convertE4XtoJSON() expects the root element of the XML file
as the argument not the whole XML file as a string.



On Tue, Jan 27, 2015 at 11:19 PM, Sabra Ossen <sa...@wso2.com> wrote:

> I didn't include it in any of my code yet. I tried it to the above
> mentioned simple xml string. Here is the code.
>
> <%
>     var utils = require('utils').xml;
>     var xmlString =
> "<employees><person><name>Tove</name><age>32</age></person><person><name>Jani</name><age>26</age></person></employees>";
>     var employeesJson = utils.convertE4XtoJSON(xmlString);
>     print(employeesJson);
>  %>
>
> On Tue, Jan 27, 2015 at 11:07 PM, Farasath Ahamed <farasa...@wso2.com>
> wrote:
>
>> Can you please post your code here? (the part you use this conversion may
>> be)
>>
>> On Tue, Jan 27, 2015 at 10:35 PM, Sabra Ossen <sa...@wso2.com> wrote:
>>
>>> Hi,
>>>
>>> The parameter passed for the method convertE4XtoJSON is String right.
>>> But I get the following error when I use the code.
>>>
>>> *org.mozilla.javascript.EcmaError: TypeError: Cannot find function
>>> localName in object
>>> <employees><person><name>Tove</name><age>32</age></person><person><name>Jani</name><age>26</age></person></employees>.
>>> (xml#49)*
>>>
>>> Is there any specific format the string needs to be in?
>>>
>>> On Tue, Jan 27, 2015 at 9:56 PM, Sabra Ossen <sa...@wso2.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I will try the package as suggested.
>>>>
>>>> Thanks.
>>>>
>>>> On Tue, Jan 27, 2015 at 9:28 PM, Buddhima Wijeweera <buddh...@wso2.com>
>>>> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> This package will help you on this:
>>>>>
>>>>> https://github.com/wso2/product-es/tree/greg-changes-asset-extensions/modules/jaggery-modules/utils
>>>>>
>>>>> Sample usage :
>>>>> var utils=require('utils').xml;
>>>>> utils.convertE4XtoJSON(<XML String>)
>>>>>
>>>>> Thanks!
>>>>>
>>>>> On Tue, Jan 27, 2015 at 9:23 PM, Sabra Ossen <sa...@wso2.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Is there any method to convert an xml string (ex :
>>>>>> "<employees><person><name>Tove</name><age>32</age></person><person><name>Jani</name><age>26</age></person></employees>")
>>>>>> to a json object using jaggery, I need to access the JSON object in
>>>>>> jaggery.
>>>>>>
>>>>>> Currently I am using JAXB to convert the xml to a Java Object and the
>>>>>> write the json in jaggery. Is there any work-around to achieve the
>>>>>> mentioned functionality.
>>>>>>
>>>>>> Any help is appreciated.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> --
>>>>>> Sabra Ossen
>>>>>> *Software Engineering Intern*
>>>>>> Mobile : +94 (0) 785 227 769
>>>>>> sa...@wso2.com
>>>>>>
>>>>>> _______________________________________________
>>>>>> Dev mailing list
>>>>>> Dev@wso2.org
>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Buddhima Wijeweera
>>>>> Software Engineer; WSO2 Inc.; http://wso2.com ,
>>>>>
>>>>> Mobile: +94 71 427 9966
>>>>> Email: buddh...@wso2.com
>>>>> Blog:   https://buddhimawijeweera.wordpress.com
>>>>> GitHub Profile: https://github.com/Buddhima
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Sabra Ossen
>>>> *Software Engineering Intern*
>>>> Mobile : +94 (0) 785 227 769
>>>> sa...@wso2.com
>>>>
>>>
>>>
>>>
>>> --
>>> Sabra Ossen
>>> *Software Engineering Intern*
>>> Mobile : +94 (0) 785 227 769
>>> sa...@wso2.com
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> *Farasath Ahamed*
>> Software Engineering Intern
>> WSO2 Inc.; http://wso2.com
>>
>> Mobile: +94 777 603 866
>> E-Mail:  farasath <http://goog_1999535192>a...@wso2.com
>>
>
>
>
> --
> Sabra Ossen
> *Software Engineering Intern*
> Mobile : +94 (0) 785 227 769
> sa...@wso2.com
>



-- 
*Farasath Ahamed*
Software Engineering Intern
WSO2 Inc.; http://wso2.com

Mobile: +94 777 603 866
E-Mail:  farasath <http://goog_1999535192>a...@wso2.com
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to