node-xml2js icon indicating copy to clipboard operation
node-xml2js copied to clipboard

Incomplete conversion

Open cosmicnag opened this issue 13 years ago • 2 comments

XML : (I know its probably not 'valid', but its what a payment gateway in India sends back.. and I have to parse it... i am obfuscating the domain name)

<result>ENROLLED</result>
<url>https://netsafeuat.somedomain.com/ACSWeb/com.enstage.entransact.servers.AccessControlServerSSL?ty=V</url>
<PAReq>eJxVUttS2zAQ/RWP37HkO82sxaQEijsNUDBtedTIwhFJZFuSg/P3lZyEi/SgPburs1e4GLcbb8eVFq0s/DDAvscla2shm8J/qq7Pzv0LAtVKcb545GxQnMCSa00b7om68C9fWZl1yfPVXY56ZYY5povxbuzXoix8AvfzB94TOAYglj+IAJ2gZVJsRaUhQFn/vbwlSRxHeQLoCGHLVbkgL1p7n87ZN4xxHOaW6WAHSbec/BK734NYexVnK9lu2mbvlbIW1AM02YG1gzRqT+I0A3QCMKgNWRnT6RlCeqqwawzXJrBRJTcBawMhUde80T1qqOHupXU9pR686g6QYwD0Ucv94CRtI46iJo9ZrfW/v9Huabkcf/a0v2ZXcv9j+edlXQByHlBbWhLhMLI39nA6S/AszQFNeqBblyp50FGUBRjb5hwU0Lk48wOwNmf6rAJbi7LDPBV8QsDHrpXcfQL0LgP6SPvyxg2EGdva5K3Cu5uwq3D7HIdxmiYYZ2l2nqduSJOL4xO2k2GCD4QOAHIk6Dh/dFwZK31Zpf9vtNKc</PAReq>
<paymentid>6756271401723481</paymentid>
<trackid>QVT-1355400371710</trackid>
<udf1></udf1>
<udf2></udf2>
<udf3></udf3>
<udf4></udf4>
<udf5></udf5>

I only get the first element i.e 'result'

What i get ;

{ result: 'ENROLLED' }

I need to get all the elements like

{result: 'ENROLLED', url: 'http://....', PAReq : '.....' .... etc}

Thanks in advance.

cosmicnag avatar Dec 13 '12 12:12 cosmicnag

For now, I added a 'root' node myself on top of the above XML and its working... is there any way otherwise?

cosmicnag avatar Dec 13 '12 12:12 cosmicnag

Well no, since this is not valid XML. You have to preprocess it anyway. Keep in mind that there's more to valid XML than just having one single root node, you need to take care about escaping ampersands.

Hmm, maybe I should make a library that mangles broken XML and creates proper XML…

Leonidas-from-XIV avatar Dec 19 '12 15:12 Leonidas-from-XIV