Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 用双引号替换双引号_Vb.net_Double_Quote - Fatal编程技术网

Vb.net 用双引号替换双引号

Vb.net 用双引号替换双引号,vb.net,double,quote,Vb.net,Double,Quote,我需要替换为完整的xml字符串 我有这个: Dim mioxml As String = "< xml version = "1.0" encoding="UTF-8"> < orderid > Range < /orderid>< operation >RangeA2< /operation>< /order>" mioxml = mioxml.Replace(""","""") 但在第一行,我有一个错误,预期指令结束

我需要替换为完整的xml字符串

我有这个:

Dim mioxml As String = "< xml version = "1.0" encoding="UTF-8"> < orderid > Range < /orderid>< operation >RangeA2< /operation>< /order>"

mioxml = mioxml.Replace(""","""")
但在第一行,我有一个错误,预期指令结束

因此,我认为问题在于mioxml的模糊性


谢谢

如果您能够在Visual Studio中使用XML文本,请看以下示例:

Dim mioxml As XDocument = New XDocument(
                              New XDeclaration("1.0", "utf-8", "yes"), 
                              <order>
                                <orderid>Range</orderid>
                                <operation>RangeA2</operation>
                              </order>)
Console.WriteLine(mioxml.ToString())

这使您可以编写XML元素,而无需担心双引号的转义。

谢谢David,这就是我根据您的建议所做的

Dim mioxml As XDocument =
<?xml version="1.0" encoding="UTF-8"?>
<orders xmlns:xsi="http//www.w3.org/2001/XMLSchema-instance">
    <order>
      <orderid>Range</orderid>
      <operation>RangeA2</operation>
    </order>
</orders>

Dim mioxml2 = mioxml.ToString
mioxml2 = mioxml2.Replace("""", """""")
MsgBox(mioxml2.ToString)

我无法更改字符串。这根绳子就像我的一样。我只需用双引号更改双引号,而不必更改字符串。我有很多这样的字符串。@riccio99那么你需要避开双引号。在VB.NET中,通过两个连续的双引号完成。例如,Dim foo As String=Hello world这是转义的。