救命! XML新手 - 需要简单的解决方案 [英] HELP! New to XML - simple solution needed
问题描述
我正在使用VB .Net并且是XML新手。
我需要创建一个包含以下行的XML文件:
<?xml version =" 1.0"编码= QUOT; UTF-8英寸?>
- < HC_DATA xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation =" ; http://.../asc.xsd">
其他东西...
< / HC_DATA>
我正在尝试使用XMLTextWriter并且可以访问模式文件asc.xsd
我可以添加到我的项目中。
任何人都可以帮助我使用VB .Net中的语法来创建这些行
使用xmlns:xsi& xsi:noNamespaceSchemaLocation?
请帮助 - 我已经在线研究了这个问题2周!!!
谢谢,
Lindy
" Lindy" <黎*** @ discussions.microsoft.com>在消息中写道
新闻:4A ********************************** @ microsof t.com ...我正在使用VB .Net并且是XML新手。
我需要创建一个包含以下行的XML文件:
<?xml version =" 1.0"编码= QUOT; UTF-8英寸?>
- < HC_DATA xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation =" http:// ... /asc.xsd">
其他东西......
< / HC_DATA>
我正在尝试使用XMLTextWriter并可以访问模式文件
asc.xsd我可以添加到我的项目中。
任何人都可以帮助我使用VB .Net中的语法,以便使用xmlns创建这些
行:xsi& xsi:noNamespaceSchemaLocation?
请帮助 - 我已经在线研究了这个问题2个星期!!!
谢谢,
Lindy
你能用这样的东西写出来吗?
昏暗作家作为xmltextwriter
writer = new xmltextwriter(somefilename,nothing)
writer.formatting = formatting.indented
writer.WriteStartDocument()
writer.WriteStartElement(someelementname)
writer.WriteString (someelementstring)
writer.WriteEndElement()
......
writer.WriteEndDocument()
writer.flush()
writer.close()
Mike
感谢Mike的回复。
我曾尝试过你的建议而我没有得到xmlns:xsi和
xsi:noNameSpaceSchemaLocation。
但是,我收到了另一篇文章的答复(在C#中我翻译成VB)。
这个新的鳕鱼e似乎有效:
Dim tw作为XmlTextWriter
FileName =" SmallTest.xml"
tw =新的XmlTextWriter(FileName,New System.Text.UTF8Encoding)
tw.WriteStartDocument()
tw.WriteStartElement(" HC_DATA")
tw.WriteAttributeString(" xmlns"," xsi",_
" http://www.w3.org/2000/xmlns/",_
" http://www.w3.org/2001/XMLSchema-instance")
tw.WriteAttributeString(" xsi"," noNamespaceSchemaLocation",_
" http://www.w3.org/2001/XMLSchema-instance"," http://example.com/asx.xsd")
tw。 WriteEndDocument()
tw.Close()
感谢您的回复
-
林迪
" vMike"写道:
Lindy <黎*** @ discussions.microsoft.com>在消息中写道
新闻:4A ********************************** @ microsof t.com。 ..我正在使用VB .Net并且是XML新手。
我需要创建一个包含以下行的XML文件:
< ;?xml version =" 1.0"编码= QUOT; UTF-8英寸?>
- < HC_DATA xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation =" http:// ... /asc.xsd">
其他东西......
< / HC_DATA>
我正在尝试使用XMLTextWriter并可以访问模式文件
asc.xsd我可以添加到我的项目中。
任何人都可以帮助我使用VB .Net中的语法来创建这些
行使用xmlns:xsi& xsi:noNamespaceSchemaLocation?
请帮助 - 我已经在线研究了这个问题2个星期!!!
谢谢,
Lindy
<你能用这样的东西写出来吗?
dim writer as xmltextwriter
writer = new xmltextwriter(somefilename,nothing)
writer.formatting = formatting.indented
writer.WriteStartDocument()
writer.WriteStartElement(someelementname)
writer.WriteString(someelementstring)
writer.WriteEndElement()
......
writer.WriteEndDocument()
writer.flush()
writer.close()
Mike
" Lindy" <黎*** @ discussions.microsoft.com>在消息中写道
新闻:FE ********************************** @ microsof t.com ...感谢Mike的回复。
我曾尝试做你的建议而且我没有得到xmlns:xsi
和xsi: noNameSpaceSchemaLocation。
然而,我收到了另一篇文章的回复(在C#中我翻译成VB)。
这个新代码似乎有效:
Dim tw作为XmlTextWriter
FileName =" SmallTest.xml"
tw =新的XmlTextWriter(FileName,New System.Text.UTF8Encoding)
tw.WriteStartDocument()
tw .WriteStartElement(" HC_DATA")
tw.WriteAttributeString(" xmlns"," xsi",_
" http://www.w3.org/2000/xmlns/", _
" http://www.w3.org/2001/XMLSchema-instance")
tw.WriteAttributeString(" xsi"," noNamespaceSchemaLocation",_
" http ://www.w3.org/2001/XMLSchema-instance",
" http://example.c om / asx.xsd")
tw.WriteEndDocument()
tw.Close()
感谢您的回复
-
Lindy
你看过
tw.WriteProcessingInstruction(" xmlns:xsi"," http://www.w3.org/2001 / XMLSchema-
instance")?
有几种方法可以做到。
Mike
I''m using VB .Net and am brand new to XML.
I need to create an XML file with the following lines:
<?xml version="1.0" encoding="UTF-8" ?>
- <HC_DATA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://.../asc.xsd">
other stuff...
</HC_DATA>
I am trying to use XMLTextWriter and have access to the schema file asc.xsd
which I can add to my project.
Can anyone help me with the syntax in VB .Net in order to create these lines
using xmlns:xsi & xsi:noNamespaceSchemaLocation?
Please help - I''ve been researching this issue online for 2 weeks!!!
Thanks,
Lindy
"Lindy" <Li***@discussions.microsoft.com> wrote in message
news:4A**********************************@microsof t.com...I''m using VB .Net and am brand new to XML.
I need to create an XML file with the following lines:
<?xml version="1.0" encoding="UTF-8" ?>
- <HC_DATA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://.../asc.xsd">
other stuff...
</HC_DATA>
I am trying to use XMLTextWriter and have access to the schema file asc.xsd which I can add to my project.
Can anyone help me with the syntax in VB .Net in order to create these lines using xmlns:xsi & xsi:noNamespaceSchemaLocation?
Please help - I''ve been researching this issue online for 2 weeks!!!
Thanks,
Lindy
Can you just write it out with something like this?
Dim writer as xmltextwriter
writer = new xmltextwriter(somefilename, nothing)
writer.formatting=formatting.indented
writer.WriteStartDocument()
writer.WriteStartElement(someelementname)
writer.WriteString(someelementstring)
writer.WriteEndElement()
......
writer.WriteEndDocument()
writer.flush()
writer.close()
Mike
Thanks Mike for your reply.
I had tried to do what you suggested and I wasn''t getting the xmlns:xsi and
xsi:noNameSpaceSchemaLocation.
However, I got a reply on another post (in C# which I translated to VB).
This new code seems to work:
Dim tw As XmlTextWriter
FileName = "SmallTest.xml"
tw = New XmlTextWriter(FileName, New System.Text.UTF8Encoding)
tw.WriteStartDocument()
tw.WriteStartElement("HC_DATA")
tw.WriteAttributeString("xmlns", "xsi", _
"http://www.w3.org/2000/xmlns/", _
"http://www.w3.org/2001/XMLSchema-instance")
tw.WriteAttributeString("xsi", "noNamespaceSchemaLocation", _
"http://www.w3.org/2001/XMLSchema-instance", "http://example.com/asx.xsd")
tw.WriteEndDocument()
tw.Close()
Thanks for your reply
--
Lindy
"vMike" wrote:
"Lindy" <Li***@discussions.microsoft.com> wrote in message
news:4A**********************************@microsof t.com...I''m using VB .Net and am brand new to XML.
I need to create an XML file with the following lines:
<?xml version="1.0" encoding="UTF-8" ?>
- <HC_DATA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://.../asc.xsd">
other stuff...
</HC_DATA>
I am trying to use XMLTextWriter and have access to the schema file
asc.xsdwhich I can add to my project.
Can anyone help me with the syntax in VB .Net in order to create these
linesusing xmlns:xsi & xsi:noNamespaceSchemaLocation?
Please help - I''ve been researching this issue online for 2 weeks!!!
Thanks,
Lindy
Can you just write it out with something like this?
Dim writer as xmltextwriter
writer = new xmltextwriter(somefilename, nothing)
writer.formatting=formatting.indented
writer.WriteStartDocument()
writer.WriteStartElement(someelementname)
writer.WriteString(someelementstring)
writer.WriteEndElement()
......
writer.WriteEndDocument()
writer.flush()
writer.close()
Mike
"Lindy" <Li***@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...Thanks Mike for your reply.
I had tried to do what you suggested and I wasn''t getting the xmlns:xsi and xsi:noNameSpaceSchemaLocation.
However, I got a reply on another post (in C# which I translated to VB).
This new code seems to work:
Dim tw As XmlTextWriter
FileName = "SmallTest.xml"
tw = New XmlTextWriter(FileName, New System.Text.UTF8Encoding)
tw.WriteStartDocument()
tw.WriteStartElement("HC_DATA")
tw.WriteAttributeString("xmlns", "xsi", _
"http://www.w3.org/2000/xmlns/", _
"http://www.w3.org/2001/XMLSchema-instance")
tw.WriteAttributeString("xsi", "noNamespaceSchemaLocation", _
"http://www.w3.org/2001/XMLSchema-instance", "http://example.com/asx.xsd")
tw.WriteEndDocument()
tw.Close()
Thanks for your reply
--
Lindy
Did you look at
tw.WriteProcessingInstruction("xmlns:xsi","http://www.w3.org/2001/XMLSchema-
instance") ?
There are probably several ways to do it.
Mike
这篇关于救命! XML新手 - 需要简单的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!