arrays - extract XML values using javascript -
i have below xml , trying extract data using java-script , ideas on converting using java script ? values xml needs exacted.
my question different ones stated :
this xml has multiple child elements , these child elements can grown 'n' number.
additional values have stored in array format .
<mergefields> <mergeitem> <key>totalpaymentamountgst </key> <value>123.56</value> </mergeitem> <mergeitem> <key>totalrefundamountgst </key> <value>123.56 </value> </mergeitem> <mergeitem> <key>totalpaymentamount </key> <value>123.56 </value> </mergeitem> <mergeitem> <key>totalrefundamount </key> <value>123.56 </value> </mergeitem> <mergeitem> <key>statementtype </key> <value>1</value> </mergeitem> <mergeitem> <key>transactions</key> <children> <mergeitem> <key> 0 </key> <children> <mergeitem> <key> paymentdate </key> <value> 2017-07-31t03:41:02.537z </value> </mergeitem> <mergeitem> <key> datepaidto </key> <value> 2017-07-31t03:41:02.537z </value> </mergeitem> <mergeitem> <key> paymentamount </key> <value> 123.56 </value> </mergeitem> <mergeitem> <key>isgstamount </key> <value>true</value> </mergeitem> <mergeitem> <key>refundamount</key> <value>123.56</value> </mergeitem> <mergeitem> <key>dishonouredamount</key> <value>123.56</value> </mergeitem> </children> </mergeitem> <mergeitem> <key> 1 </key> <children> <mergeitem> <key>paymentdate </key> <value>2017-07-31t03:41:02.537z</value> </mergeitem> <mergeitem> <key>datepaidto </key> <value>2017-07-31t03:41:02.537z</value> </mergeitem> <mergeitem> <key>paymentamount </key> <value>123.56</value> </mergeitem> <mergeitem> <key>isgstamount</key> <value> true</value> </mergeitem> <mergeitem> <key> refundamount </key> <value> 123.56</value> </mergeitem> <mergeitem> <key>dishonouredamount </key> <value> 123.56 </value> </mergeitem> </children> </mergeitem> </children> </mergeitem> </mergefields>
xml2js npm package should able help, @ this answer
Comments
Post a Comment