This article can be found on the Integration Manager Menu.
A client recently called with an issue with importing an XML file using Integration Manager (IM). Apparently, IM can't read the attributes in an XML document. After trying for a while to get it to work, we decided to write a small application that would parse the XML file and move the attributes to nodes.
Today’s task has to do with an XML document that has the form:
<
OutboundReports
>
<
InvoiceNotice
>
<
InvoiceNoticeHeader
InvoiceDate
=
"20100607"
InvoiceType
=
"Invoice"
invoiceID
=
"60252726"
purpose
=
"PR"
>
</
InvoiceNoticeHeader
>
</
InvoiceNotice
>
<
InvoiceNotice
>
<
InvoiceNoticeHeader
InvoiceDate
=
"20100607"
InvoiceType
=
"Invoice"
invoiceID
=
"60252727"
purpose
=
"PR"
>
</
InvoiceNoticeHeader
>
</
InvoiceNotice
>
</
OutboundReports
>
We need to move the InvoiceDate, InvoiceType, and invoiceID attributes to ‘nodes’, so that our integration program will see them, the current version will not read attributes. Here’s what we want it to look like in the end:
<
OutboundReports
>
<
InvoiceNotice
>
<
InvoiceNoticeHeader
InvoiceDate
=
"20100607"
InvoiceType
=
"Invoice"
invoiceID
=
"60252726"
purpose
=
"PR"
>
<
InvoiceDate
>20100607</
InvoiceDate
>
<
InvoiceType
>Invoice</
InvoiceType
>
<
InvoiceID
>60252726</
InvoiceID
>
</
InvoiceNoticeHeader
>
</
InvoiceNotice
>
<
InvoiceNotice
>
<
InvoiceNoticeHeader
InvoiceDate
=
"20100607"
InvoiceType
=
"Invoice"
invoiceID
=
"60252727"
purpose
=
"PR"
>
<
InvoiceDate
>20100607</
InvoiceDate
>
<
InvoiceType
>Invoice</
InvoiceType
>
<
InvoiceID
>60252726</
InvoiceID
>
</
InvoiceNoticeHeader
>
</
InvoiceNotice
>
</
OutboundReports
>
Here’s the code: