loadXmlFile in AC

Avatar

Avatar

vendimb15716755

Avatar

vendimb15716755

vendimb15716755

15-11-2017

HI

I am trying to load data from an XML file to a custom Schema created on the campaign. the file will come everyday so I will do an incremental load. the file is around 200 MB . with that says what are the options? when I use the file load task on the workflow seems like not mapping it correctly and I dont see that its build for xml ( looks like only Flat files and csv) unless I am missing something?

Also I looked at the js Api documentation and there is loadXmlFile(filename [, noErr ]) function .

anyone can give me a suggestions?

below is a sample xml that I will be loading

h<ns2:LocalProductRebatesFeed revision="1510506426939" siteId="test" xsi:schemaLocation="http://api.test.com/schema/feeds /api/schema/feeds.xsd">
<localProductRebateSets>
<localProductRebateSet siteSKU="Test1234" zipCode="10119" hash="-1400618753">
<programSet redemptionMethod="MAIL_IN">
<grandTotal>
<maxAmountUSD>50.00</maxAmountUSD>
<programIDs>
<id>21858</id>
</programIDs>

</grandTotal>

<programIDs>
<id>21858</id>

</programIDs>

</programSet>

</localProductRebateSet>

</localProductRebateSets>

#<products>
<product price="699.00" efficiencyLevelLabel="Meets CEE Tier I criteria" hash="-402127190" siteSKU="test1234" brand="test" mpn="test12345" pdpURL="https://www.test.com/Search-Results.html?term=test1234" imageURL="http://access.test.com/mr/getMediaType.do?mediaType=AB-Thumbnail_100X100_HO&sku=test1234" upc="883049409122" category="Dishwasher"/>

</products>

<programs>
<program hash="961304896" name="ConEdison (Electric) - NY" id="21858" homeURL="https://www.coned.com/en/save-money/rebates-incentives-tax-credits/rebates-incentives-tax-credits-fo..." claimFormURL="https://conedisonresidential.com/appliance" amountLabel="$50" startPurchaseDate="2017-01-01" endPurchaseDate="2017-12-31" postEndDateSubmitWindow="16" postPurchaseSubmitWindow="0" redemptionMethod="MAIL_IN">
<purchaseRebate>
<units>USD</units>
<amount>50.00</amount>

</purchaseRebate>

<importantDetails>
<item>Cannot be combined with other utility rebates.</item>
<item>Must be a residential electric customer of participating utility.</item>
<item>Proof of purchase required.</item>
</importantDetails>
<doubleDipping>
<allowed>false</allowed>
<exceptedProgramIDs/>

</doubleDipping>

<recyclingRebate>
<units>USD</units>
<amount>0.00</amount>

</recyclingRebate>

<validDates>
<item>Purchase between Jan 1, 2017 and Dec 31, 2017</item>

<item>Claim by Jan 16, 2018</item>

</validDates>

</program>

</programs>

</ns2:LocalProductRebatesFeed>

Replies

Avatar

Avatar

florentlb

Avatar

florentlb

florentlb

04-12-2017

Hi Vendim,

I'm pasting here the last DM I shared in case it can be used by other members:

So the loadXmlFile function is deprecated. You can use instead the load (DOMDocument) function (which contains a basic example in the JSAPI documentation) and combine with other reading functions such as getElements and getValue.

For example, for an XML file containing products like this:

<product>

  <name>abc</name>

  <code>123</code>

</product>

You can start using something like this in a JS activity:

var doc = DOMDocument.load("data/test.xml");

var products = doc.root.getElements("product");

for (var i=0; i<product.length; i++) {

var product = products[i];

var name = product.getValue("name");

var code = product.getValue("code");

}

I don't have much JS knowledge but starting from this you should be able to apply the processing you want on the data, for example to transform the XML in a more readable format. After the JS activity you could use a data loading (file) activity and then update the database.

Florent