Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

< literal symbol in XML 2

Status
Not open for further replies.

ajikoe

Programmer
Apr 16, 2004
71
ID
Hello,

I would like to make XML comment but it include a symbol <. How can I treat it literally?

Example:
<remarks>Helo <world> </remarks>

Thanks
Pujo
 
You would need to use the CDATA construct:

<remarks><![CDATA["Helo <world> "]]></remarks>

More info:

-paul

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
If you are writing XML, you xcan avoid trouble by using the XMLTextWriter.

Dim sb As New StringBuilder(150)
Dim sw As New IO.StringWriter(sb)
Dim xtW As New Xml.XmlTextWriter(sw)

xtW.WriteStartElement("SDPCIP30")
xtW.WriteStartElement("TSHeader")
xtw.WriteElementString("SerNbr", _
TrimNumber(m_d.SerialNbr).PadLeft(10, "0"c))
xtW.WriteEndElement()
xtW.WriteEndElement()
xtW.Close()

Dim sXml as String = sb.Tostring

Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
Another vote for the XmlTextWriter. It will handle the entity conversions for you.

Same for using an XmlTextReader when reading an XML file -- it will convert the entity back to it's equivalent character.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top