VB generates an xml file and uses xsd for verification. xmlxsd

Source: Internet
Author: User

VB generates an xml file and uses xsd for verification. xmlxsd

A customer needs to send data in xml format.

Vb implementation code

Private Function createXML_old (ByVal xmlName As String) As Boolean
Directory for storing xml generated by Dim SrcPath As String = "c \ project \ srcXmlFiles \"'
Try Dim writer As New System. Xml. XmlTextWriter (SrcPath & xmlName, System. Text. Encoding. UTF8) Dim namespaceUrl As String =" http://www.xxx.com "'NamespaceUrl writer used to verify xsd. formatting = Formatting. indented writer. writeStartDocument () writer. writeStartElement ("root", "test", namespaceUrl) writer. writeElementString ("firstNode1", "values") writer. writeElementString ("firstNode2", "values") writer. writeElementString ("firstNode3", "values") writer. writeElementString ("firstNode4", "values) writer. writeElementString ("firstNode5", values) writer. writeElementString ("firstNode6Id", values) Dim dv As DataView = cn. getData. defaultView () If dv. count> 0 Then For Each item As DataRowView In dv writer. writeStartElement ("firstNode7") writer. writeElementString ("secondNode1", values) writer. writeElementString ("secondNode2", values) writer. writeElementString ("secondNode3", values) Dim dv2 As DataView = cn. getData2 (item ("firstNode6Id ")). defaultView () If dv2.Count> 0 Then For Each itemRMDetails As DataRowView In dvRMDetails writer. writeStartElement ("secondNode4") writer. writeStartElement ("thridNode1") writer. writeElementString ("thridNode2", values) writer. writeEndElement () 'disable secondNode4 writer. writeEndElement () 'disable thridNode1 Next Else writer. writeStartElement ("secondNode4") writer. writeStartElement ("thridNode1") writer. writeElementString ("thridNode2", "") writer. writeEndElement () 'disable secondNode4 writer. writeEndElement () 'disable thridNode1 End If writer. writeEndElement () 'disable firstNode7 Next
Else
'Writelog Function End If writer. writeEndElement () writer. writeEndDocument () 'writer. close () 'write XML into the file and Close writer Return True Catch ex As Exception Return False End Try End Function

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.