The ':' character, hexadecimal value 0x3A, cannot be included in a nameThe ':' character, hexadecimal value 0x3A, cannot be included in a name

  • Thread starter Thread starter monzer ahmed
  • Start date Start date
M

monzer ahmed

Guest
I'm trying to write a code to insert items in exist xml file ,I want the items in file to be like this:

<item>
<title><![CDATA[any title]]></title>
<link>http://any link</link>
<pubDate>any date</pubDate>
<guid isPermaLink="true">any link</guid>
<description><![CDATA[any description]]></description>
<media:credit role="author"><![CDATA[any author]]></media:credit>
<media:category><![CDATA[any category]]></media:category>
<media:content url="http://any link" height="266" width="127" />
<media:thumbnail url="http://any link" height="266" width="127" />
</item>


so I have write this code :


Dim FilePath As String
FilePath = "C:\Users\MONZER\Desktop\Karary Web Site\WebApplication1\XMLFile1.xml"
Dim document As New XDocument
If File.Exists(FilePath) Then
document = XDocument.Load(FilePath)
Else
Label1.Text = "not done"
End If

Dim root = New XElement("item")
Dim title = New XElement("title", "<![CDATA[" & TextBox3.Text & "]]>")
Dim link = New XElement("link", TextBox6.Text)
Dim pubDate = New XElement("pubDate", DateTime.Now.ToString("yyy/MM/dd HH:mm"))
Dim description = New XElement("description", TextBox5.Text)
Dim author = New XElement("media:credit",
New XAttribute("role", "author"),
New XAttribute("><![CDATA[", TextBox5.Text + "]]>"))

root.Add(title, link, pubDate, description, author)
document.Root.Add(root)
document.Save(FilePath)
Label1.Text = "done"

End Sub


I got this error :The ':' character, hexadecimal value 0x3A, cannot be included in a name.

Continue reading...
 
Back
Top