Not sure exactly how to do, I have the XML file being created, but I am
missing a node that should have the other elements as "SUB CHILD" under it -
the file should look like

<?xml version="1.0" encoding="utf-8" ?>
- <ImportPayments>
- <Payment>
<ReceiptType>1</ReceiptType>
<ReceiptMethod>2</ReceiptMethod>
<ReceiptRef>1834</ReceiptRef>
<ReceivedFrom>1</ReceivedFrom>
<AccountNumber>6116242</AccountNumber>
<Amount>191.8</Amount>
<BankAccountID>12</BankAccountID>
<DeclineReinstatement>0</DeclineReinstatement>
</Payment>
</ImportPayments>

But mine looks like - I am missing the PAYMENT Node - can anyone tell me how
to get that added or am i just being totally stupid - I would lean toward
the latter LOL - Below is a copy of the script
<?xml version="1.0" encoding="utf-8" ?>
- <ImportPayments>
<ReceiptType>1</ReceiptType>
<ReceiptMethod>2</ReceiptMethod>
<ReceiptRef>1834</ReceiptRef>
<ReceivedFrom>1</ReceivedFrom>
<AccountNumber>6116242</AccountNumber>
<Amount>191.8</Amount>
<BankAccountID>12</BankAccountID>
<DeclineReinstatement>0</DeclineReinstatement>
</ImportPayments>

Dim xmlDoc, rootEl, p
Dim fieldReceiptType, fieldReceiptMethod, fieldReceiptRef, fieldReceivedFrom
Dim fieldAccountNumber, fieldAmount, fieldBankAccountID,
fieldDeclineReinstatement

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.preserveWhiteSpace = True 'Create a root element and append it to
the document

Set rootEl = xmlDoc.createElement("ImportPayments")
xmlDoc.appendChild rootEl

Set fieldName = xmlDoc.createElement("Payment")
Set fieldReceiptType = xmlDoc.createElement("ReceiptType")
Set fieldReceiptMethod = xmlDoc.createElement("ReceiptMethod")
Set fieldReceiptRef = xmlDoc.createElement("ReceiptRef")
Set fieldReceivedFrom = xmlDoc.createElement("ReceivedFrom")
Set fieldAccountNumber = xmlDoc.createElement("AccountNumber")
Set fieldAmount = xmlDoc.createElement("Amount")
Set fieldBankAccountID = xmlDoc.createElement("BankAccountID")
Set fieldDeclineReinstatement = xmlDoc.createElement("DeclineReinstatement")

fieldReceiptType.Text = "1"
fieldReceiptMethod.Text = "2"
fieldReceiptRef.Text = "1834"
fieldReceivedFrom.Text = "1"
fieldAccountNumber.Text = "6116242"
fieldAmount.Text = "191.8"
fieldBankAccountID.Text = "12"
fieldDeclineReinstatement.Text = "0"

rootEl.appendChild fieldReceiptType
rootEl.appendChild fieldReceiptMethod
rootEl.appendChild fieldReceiptRef
rootEl.appendChild fieldReceivedFrom
rootEl.appendChild fieldAccountNumber
rootEl.appendChild fieldAmount
rootEl.appendChild fieldBankAccountID
rootEl.appendChild fieldDeclineReinstatement

'Add an XML processing instruction
'and insert it before the root element
Set p=xmlDoc.createProcessingInstruction("xml","version='1.0'")
xmlDoc.insertBefore p,xmlDoc.childNodes(0)

'Save the XML file to the c directory
xmlDoc.Save "c:\trash\test.xml"

'Release all object references
Set xmlDoc = nothing
Set rootEl = nothing
Set fieldReceiptType = nothing
Set fieldReceiptMethod = nothing
Set fieldReceiptRef = nothing
Set fieldReceivedFrom = nothing
Set fieldAccountNumber = nothing
Set fieldAmount = nothing
Set fieldBankAccountID = nothing
Set fieldDeclineReinstatement = nothing
Set fieldName=nothing
Set p = nothing

RE: Create a "SUB CHILD" for XML File by v-kevy

v-kevy
Wed Aug 17 21:39:08 CDT 2005

Hi Scott,

All the elements were added under ImportPayments because in your script,
you used rootEl.appendChild to add the elements. Here, I made some changes
to your script and it works fine on my machine. HTH.

Dim xmlDoc, rootEl, p
Dim fieldReceiptType, fieldReceiptMethod, fieldReceiptRef, fieldReceivedFrom
Dim fieldAccountNumber, fieldAmount, fieldBankAccountID,
fieldDeclineReinstatement

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.preserveWhiteSpace = True 'Create a root element and append it to
the document

Set rootEl = xmlDoc.createElement("ImportPayments")
xmlDoc.appendChild rootEl

Set fieldName = xmlDoc.createElement("Payment")
Set fieldReceiptType = xmlDoc.createElement("ReceiptType")
Set fieldReceiptMethod = xmlDoc.createElement("ReceiptMethod")
Set fieldReceiptRef = xmlDoc.createElement("ReceiptRef")
Set fieldReceivedFrom = xmlDoc.createElement("ReceivedFrom")
Set fieldAccountNumber = xmlDoc.createElement("AccountNumber")
Set fieldAmount = xmlDoc.createElement("Amount")
Set fieldBankAccountID = xmlDoc.createElement("BankAccountID")
Set fieldDeclineReinstatement = xmlDoc.createElement("DeclineReinstatement")

fieldReceiptType.Text = "1"
fieldReceiptMethod.Text = "2"
fieldReceiptRef.Text = "1834"
fieldReceivedFrom.Text = "1"
fieldAccountNumber.Text = "6116242"
fieldAmount.Text = "191.8"
fieldBankAccountID.Text = "12"
fieldDeclineReinstatement.Text = "0"

rootEl.appendChild fieldName
fieldName.appendChild fieldReceiptType
fieldName.appendChild fieldReceiptMethod
fieldName.appendChild fieldReceiptRef
fieldName.appendChild fieldReceivedFrom
fieldName.appendChild fieldAccountNumber
fieldName.appendChild fieldAmount
fieldName.appendChild fieldBankAccountID
fieldName.appendChild fieldDeclineReinstatement

'Add an XML processing instruction
'and insert it before the root element
Set p=xmlDoc.createProcessingInstruction("xml","version='1.0'")
xmlDoc.insertBefore p,xmlDoc.childNodes(0)

'Save the XML file to the c directory
xmlDoc.Save "c:\test.xml"

'Release all object references
Set xmlDoc = nothing
Set rootEl = nothing
Set fieldReceiptType = nothing
Set fieldReceiptMethod = nothing
Set fieldReceiptRef = nothing
Set fieldReceivedFrom = nothing
Set fieldAccountNumber = nothing
Set fieldAmount = nothing
Set fieldBankAccountID = nothing
Set fieldDeclineReinstatement = nothing
Set fieldName=nothing
Set p = nothing

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Re: Create a "SUB CHILD" for XML File by Scott

Scott
Thu Aug 18 05:51:06 CDT 2005

Thanks - that worked - I have one last question. If I wanted to Loop
through a result set and have the PAYMENT node with the other SUB-CHILD
nodes created until i get to the end of results then close the ImportPayment
Tag - could you give me a breif sample of that inside this script?

Thanks again for the help.
"Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
news:Ki2nG45oFHA.588@TK2MSFTNGXA01.phx.gbl...
> Hi Scott,
>
> All the elements were added under ImportPayments because in your script,
> you used rootEl.appendChild to add the elements. Here, I made some changes
> to your script and it works fine on my machine. HTH.
>
> Dim xmlDoc, rootEl, p
> Dim fieldReceiptType, fieldReceiptMethod, fieldReceiptRef,
fieldReceivedFrom
> Dim fieldAccountNumber, fieldAmount, fieldBankAccountID,
> fieldDeclineReinstatement
>
> Set xmlDoc = CreateObject("Microsoft.XMLDOM")
> xmlDoc.preserveWhiteSpace = True 'Create a root element and append it to
> the document
>
> Set rootEl = xmlDoc.createElement("ImportPayments")
> xmlDoc.appendChild rootEl
>
> Set fieldName = xmlDoc.createElement("Payment")
> Set fieldReceiptType = xmlDoc.createElement("ReceiptType")
> Set fieldReceiptMethod = xmlDoc.createElement("ReceiptMethod")
> Set fieldReceiptRef = xmlDoc.createElement("ReceiptRef")
> Set fieldReceivedFrom = xmlDoc.createElement("ReceivedFrom")
> Set fieldAccountNumber = xmlDoc.createElement("AccountNumber")
> Set fieldAmount = xmlDoc.createElement("Amount")
> Set fieldBankAccountID = xmlDoc.createElement("BankAccountID")
> Set fieldDeclineReinstatement =
xmlDoc.createElement("DeclineReinstatement")
>
> fieldReceiptType.Text = "1"
> fieldReceiptMethod.Text = "2"
> fieldReceiptRef.Text = "1834"
> fieldReceivedFrom.Text = "1"
> fieldAccountNumber.Text = "6116242"
> fieldAmount.Text = "191.8"
> fieldBankAccountID.Text = "12"
> fieldDeclineReinstatement.Text = "0"
>
> rootEl.appendChild fieldName
> fieldName.appendChild fieldReceiptType
> fieldName.appendChild fieldReceiptMethod
> fieldName.appendChild fieldReceiptRef
> fieldName.appendChild fieldReceivedFrom
> fieldName.appendChild fieldAccountNumber
> fieldName.appendChild fieldAmount
> fieldName.appendChild fieldBankAccountID
> fieldName.appendChild fieldDeclineReinstatement
>
> 'Add an XML processing instruction
> 'and insert it before the root element
> Set p=xmlDoc.createProcessingInstruction("xml","version='1.0'")
> xmlDoc.insertBefore p,xmlDoc.childNodes(0)
>
> 'Save the XML file to the c directory
> xmlDoc.Save "c:\test.xml"
>
> 'Release all object references
> Set xmlDoc = nothing
> Set rootEl = nothing
> Set fieldReceiptType = nothing
> Set fieldReceiptMethod = nothing
> Set fieldReceiptRef = nothing
> Set fieldReceivedFrom = nothing
> Set fieldAccountNumber = nothing
> Set fieldAmount = nothing
> Set fieldBankAccountID = nothing
> Set fieldDeclineReinstatement = nothing
> Set fieldName=nothing
> Set p = nothing
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



Re: Create a "SUB CHILD" for XML File by v-kevy

v-kevy
Fri Aug 19 03:11:24 CDT 2005

Hi Scott,

I don't quite understand you. What do you mean by loop through a result
set? What is the result set come from? Could you show me how you need the
result xml document look like?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Re: Create a "SUB CHILD" for XML File by Scott

Scott
Mon Aug 22 10:03:39 CDT 2005

Like this - does that help?

<?xml version="1.0" encoding="utf-8" ?>

- <ImportPayments>

- <Payment>

<ReceiptType>1</ReceiptType>

<ReceiptMethod>2</ReceiptMethod>

<ReceiptRef>1834</ReceiptRef>

<ReceivedFrom>1</ReceivedFrom>

<AccountNumber>6116242</AccountNumber>

<Amount>191.8</Amount>

<BankAccountID>12</BankAccountID>

<DeclineReinstatement>0</DeclineReinstatement>

</Payment>

- <Payment>

<ReceiptType>1</ReceiptType>

<ReceiptMethod>2</ReceiptMethod>

<ReceiptRef>9524</ReceiptRef>

<ReceivedFrom>1</ReceivedFrom>

<AccountNumber>6116253</AccountNumber>

<Amount>84.34</Amount>

<BankAccountID>12</BankAccountID>

<DeclineReinstatement>0</DeclineReinstatement>

</Payment>

- <Payment>

<ReceiptType>1</ReceiptType>

<ReceiptMethod>2</ReceiptMethod>

<ReceiptRef>0288</ReceiptRef>

<ReceivedFrom>1</ReceivedFrom>

<AccountNumber>6116400</AccountNumber>

<Amount>230.37</Amount>

<BankAccountID>12</BankAccountID>

<DeclineReinstatement>0</DeclineReinstatement>

</Payment>

</ImportPayments>

"Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
news:ejT9fWJpFHA.3120@TK2MSFTNGXA01.phx.gbl...
> Hi Scott,
>
> I don't quite understand you. What do you mean by loop through a result
> set? What is the result set come from? Could you show me how you need the
> result xml document look like?
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



Re: Create a "SUB CHILD" for XML File by v-kevy

v-kevy
Tue Aug 23 00:25:25 CDT 2005

Hi Scott,

Here, you need to put a For...Next statement in the code to repeat the node
adding operation. Also, you can change the fixed text values to the data
source you're getting values from.

Dim xmlDoc, rootEl, p
Dim fieldReceiptType, fieldReceiptMethod, fieldReceiptRef, fieldReceivedFrom
Dim fieldAccountNumber, fieldAmount, fieldBankAccountID,
fieldDeclineReinstatement
Dim i

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.preserveWhiteSpace = True 'Create a root element and append it to
the document

Set rootEl = xmlDoc.createElement("ImportPayments")
xmlDoc.appendChild rootEl

'Begin loop
For i=0 to 1
Set fieldName = xmlDoc.createElement("Payment")
Set fieldReceiptType = xmlDoc.createElement("ReceiptType")
Set fieldReceiptMethod = xmlDoc.createElement("ReceiptMethod")
Set fieldReceiptRef = xmlDoc.createElement("ReceiptRef")
Set fieldReceivedFrom = xmlDoc.createElement("ReceivedFrom")
Set fieldAccountNumber = xmlDoc.createElement("AccountNumber")
Set fieldAmount = xmlDoc.createElement("Amount")
Set fieldBankAccountID = xmlDoc.createElement("BankAccountID")
Set fieldDeclineReinstatement = xmlDoc.createElement("DeclineReinstatement")

'Change the following strings to data source values.
fieldReceiptType.Text = "1"
fieldReceiptMethod.Text = "2"
fieldReceiptRef.Text = "1834"
fieldReceivedFrom.Text = "1"
fieldAccountNumber.Text = "6116242"
fieldAmount.Text = "191.8"
fieldBankAccountID.Text = "12"
fieldDeclineReinstatement.Text = "0"

rootEl.appendChild fieldName
fieldName.appendChild fieldReceiptType
fieldName.appendChild fieldReceiptMethod
fieldName.appendChild fieldReceiptRef
fieldName.appendChild fieldReceivedFrom
fieldName.appendChild fieldAccountNumber
fieldName.appendChild fieldAmount
fieldName.appendChild fieldBankAccountID
fieldName.appendChild fieldDeclineReinstatement

Next

'Add an XML processing instruction
'and insert it before the root element
Set p=xmlDoc.createProcessingInstruction("xml","version='1.0'")
xmlDoc.insertBefore p,xmlDoc.childNodes(0)

'Save the XML file to the c directory
xmlDoc.Save "c:\test.xml"

'Release all object references
Set xmlDoc = nothing
Set rootEl = nothing
Set fieldReceiptType = nothing
Set fieldReceiptMethod = nothing
Set fieldReceiptRef = nothing
Set fieldReceivedFrom = nothing
Set fieldAccountNumber = nothing
Set fieldAmount = nothing
Set fieldBankAccountID = nothing
Set fieldDeclineReinstatement = nothing
Set fieldName=nothing
Set p = nothing

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."