Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

parse xml passed inside <ctx> for Transactional template

Avatar

Level 3

Hi All,

 

i am getting the below xml inside my ctx of rt event

<ctx>

                <userMessage>

                    <userData>

                        <abc.alpha.new.system.User>

                            <userType>Fixed</userType>

                            <userBackground>Regular</ userBackground>

                            <productBookingDate>2015-05-8</productBookingDate >

 

when I am using --->  rtEvent.ctx.userMessage.userData.abc.alpha.new.system.User.userBackground ----- i am getting empty value
even if I use rtEvent.ctx.userMessage.userData.("abc.alpha.new.system.User").userBackground i still get empty value

 

Kindly suggest how to parse this xml to retrieve the value of 'userBackground' 

Please

 

@Vipul_Raghav 

@Manoj_Kumar_ 

@ShrawanSaxena 

2 Replies

Avatar

Community Advisor

Hi @bhaskarc1289447 

Can you try this ? :

 

var doc = DOMDocument.fromXMLString(
    '<?xml version="1.0" encoding="ISO-8859-1"?>' +
    rtEvent.ctx.toXMLString());

var userBackground = doc.root.getElements('userMessage')[0]
                  .getElements('userData')[0]
                  .getElements('abc.alpha.new.system.User')[0]
                  .getElements('userBackground')[0].textContent;

Cedric

 

Avatar

Administrator

Hi @bhaskarc1289447,

Was the given solution helpful to resolve your query or do you still need more help here? Do let us know.

Thanks!