Vb.net 用双引号替换双引号
我需要替换为完整的xml字符串 我有这个: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(""","""") 但在第一行,我有一个错误,预期指令结束
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这是转义的。