VB generates an XML file and uses XSD validation

Source: Internet
Author: User

A need for a recent customer that requires data to be sent in XML form.

VB implementation code

Private FunctionCreatexml_old (ByValXMLName as String) as Boolean
Dim Srcpath as String = "C\project\srcxmlfiles\" ' generated XML stored directory
Try DimWriter as NewSystem.Xml.XmlTextWriter (Srcpath &XMLName, System.Text.Encoding.UTF8)DimNamespaceurl as String="http://www.xxx.com"' Verify that XSD needs to be used for Namespaceurlwriter. 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)DimDv asDataView =Cn.getData.DefaultView ()IfDv. Count >0 Then for eachItem asDataRowViewinchDV Writer. WriteStartElement ("FirstNode7") writer. WriteElementString ("SecondNode1", values) writer. WriteElementString ("SecondNode2", values) writer. WriteElementString ("SecondNode3", values)DimDv2 asDataView = CN.GETDATA2 (Item ("Firstnode6id")). DefaultView ()IfDv2. Count >0 Then for eachItemrmdetails asDataRowViewinchdvrmdetails Writer. WriteStartElement ("SecondNode4") writer. WriteStartElement ("ThridNode1") writer. WriteElementString ("ThridNode2", values)writer. WriteEndElement ()'Close SecondNode4Writer. WriteEndElement ()'Close ThridNode1 Next Elsewriter. WriteStartElement ("SecondNode4") writer. WriteStartElement ("ThridNode1") writer. WriteElementString ("ThridNode2","") writer. WriteEndElement ()'Close SecondNode4Writer. WriteEndElement ()'Close ThridNode1 End Ifwriter. WriteEndElement ()'Close FirstNode7 Next
Else
' Writelog FunctionEnd Ifwriter. WriteEndElement () writer. WriteEndDocument ()'Writer. Close ()'write XML to file and close writer Return True CatchEx asExceptionReturn False End Try End Function

VB generates an XML file and uses XSD validation

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.