How to extract all xml data (including xml tags) using Suitescript

  Kiến thức lập trình

Hope you can help. I am currently assessing the best way to extract ALL ‘OrderLevel’ tags (this would include both tags and values) from an XML file in SuiteScript 2.1.

Here’s an example snippet:

<RootLevel>
  <OrderLevel>
    <PurchaseOrderNumber>123</PurchaseOrderNumber>
      <item>fridge</item>
    <PurchaseOrderDate/>
    <Vendor>abc</Vendor>
  </OrderLevel>
  <OrderLevel>
    <PurchaseOrderNumber>456</PurchaseOrderNumber>
      <item>cupboard</item>
    <PurchaseOrderDate/>
    <Vendor>def</Vendor>
  </OrderLevel>
</RootLevel>

This is a very simple example of course. I was considering using a REGEX pattern, but I would rather a method that is considered best practice.

The whole goal of this exercise is to combine all tags from multiple XML files into one single XML file. To be clear, I do not want just the values, but also the tags.

Thoughts?

LEAVE A COMMENT