使用VB.NET创建XML文件 [英] Create XML File Using VB.NET
问题描述
您好,
我想创建一个像
的Xml文件
Hi Folks,
I want to create a Xml file Like
<?xml version="1.0" encoding="UTF-8"?>
<NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd">
<Header version="8.0" action="read" objectType="contentPack" externalSource="NIKU">
<!-- you change the order by simply swap 1 and 2 number in the name attribute -->
<args name="order_by_1" value="code"/>
<args name="documentLocation" value="C:\niku"/>
</Header>
<PortletQuery>
<Filter name="code" criteria="EQUALS">xogHelloWorld</Filter>
</PortletQuery>
</NikuDataBus>
请帮帮我!
谢谢,
Adersh Ram BK
Please Help me !
Thanks,
Adersh Ram BK
推荐答案
这是我对.NET中已有内容的简短概述:
This is my short overview of what you already have from .NET:
- 使用
System.Xml.XmlDocument
类.它实现了DOM接口;如果文档太大,则这种方法最简单,也足够好.
请参见 ^ ]. - 使用类
System.Xml.XmlTextWriter
和System.Xml.XmlTextReader
;这是最快的读取方法,尤其是您需要跳过一些数据.
请参见 http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx [ http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx [ http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [http://msdn.microsoft.com/en-us/library/bb387063.aspx [
- Use
System.Xml.XmlDocument
class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^]. - Use the classes
System.Xml.XmlTextWriter
andSystem.Xml.XmlTextReader
; this is the fastest way of reading, especially is you need to skip some data.
See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^]. - Use the class
System.Xml.Linq.XDocument
; this is the most adequate way similar to that ofXmlDocument
, supporting LINQ to XML Programming.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].
另外,我不确定您是否真的需要直接编写/读取XML.您可能需要使用序列化:
http://en.wikipedia.org/wiki/Serialization#.NET_Framework [ http://msdn.microsoft.com/en-us/library/7ay27kt9%28v = vs.110%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/ms233843.aspx [ ^ ].
几乎最全面,最易于使用的序列化方法是基于数据协定的方法:
http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ].
在我倡导这种方法的地方,也请参阅我过去的答案:
如何在我的表单应用程序? [ ^ ],
创建属性文件... [
Also, I''m not sure that you really need to write/read XML directly. Chances are, you need to use Serialization:
http://en.wikipedia.org/wiki/Serialization#.NET_Framework[^],
http://msdn.microsoft.com/en-us/library/7ay27kt9%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/ms233843.aspx[^].
Nearly the most comprehensive and easy-to-use method of serialization is the one based on Data Contract:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].
Please also see my past answers where I advocate this approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].
Good luck,
这篇关于使用VB.NET创建XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!