Link to home
Create AccountLog in
Avatar of TrialUser
TrialUserFlag for Afghanistan

asked on

closing xml tags vb.net

I am creating a xml file. In the attcahed file under the Order node, I am trying to create multiple like items using the OrderLine, OrderLineTranQuantity and so on. However I would need the tag to clse before the next line item starts. Something like :
<orderlines>
<orderline primelineno>
<orderlinetranquantity>
<item
</item>
</orderlinetranquantity>
</orderlineprimelineno>

<orderline primelineno>
<orderlinetranquantity>
<item
</item>
</orderlinetranquantity>
</orderlineprimelineno>
</orderlines>

However it looks nested in the way my file it was created.

The code I have used is as follows. Please suggest how I can get it to the above format.
  writer.WriteStartElement("OrderLines")

        Dim bolPlaceOrder As Boolean = False
        For Each drPODetailLines In dtPODetailLines.Rows
            If drPODetailLines.Item("POLNESTA") = 1 Then
                bolPlaceOrder = True 'order contained at least one item
                intRow += 1
                intQuantity = drPODetailLines.Item("QTYORDER")
                intTotalQuantity += intQuantity
                strUnits = drPODetailLines.Item("UOFM").Trim
                strSKU = drPODetailLines.Item("VNDITNUM").Trim
                varCost = drPODetailLines.Item("UNITCOST")
                strShortDesc = drPODetailLines.Item("VNDITDSC").Trim

                writer.WriteStartElement("OrderLine")
                writer.WriteAttributeString("CustomerLinePONo", strTransactionID)
                writer.WriteAttributeString("PrimeLineNo", intRow)

                writer.WriteStartElement("OrderLineTranQuantity")
                writer.WriteAttributeString("OrderedQty", intQuantity)
                writer.WriteAttributeString("TransactionalUOM", strUnits)

                writer.WriteStartElement("Item")
                writer.WriteAttributeString("CustomerItem", strSKU)
            End If
        Next '
        writer.WriteEndElement()
        writer.WriteEndDocument()
        writer.Close()
Thanks
ASKER CERTIFIED SOLUTION
Avatar of james-ct16
james-ct16
Flag of Australia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Kumaraswamy R
Hi

Bellow Url Give some information our ur Issue

http://vb.net-informations.com/xml/create-xml-vb.net.htm