如何插入?
Dim SpCharacter As String = " " "
或
Dim XMLSitemap As String = "<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">"
插入所有内容“和&gt; 等
答案 0 :(得分:1)
你需要通过加倍来逃避它:
Dim SpCharacter As String = " "" "
Dim XMLSitemap As String = "<urlset xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"">"
请参阅MSDN上的String Basics in Visual Basic:
Visual Basic将字符串文字中的两个引号解释为字符串中的一个引号。
答案 1 :(得分:0)
在VB.NET中,您可以通过连续两次传递来转义"
:
Dim SpCharacter As String = " "" "
或
Dim XMLSitemap As String = "<urlset xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"">"