472,795 Members | 2,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,795 software developers and data experts.

xmldocument " and "

Hi,

I would be extremly grateful for some help on producing an xml fragemt.

The fragment that I wish to produce should look like this

<Addresses>
<Address>&qout;Somebody's Name&quot; &lt;me@mydomain.com&gt;</Address>
</Addresses>

This looks simple enough however I am having great difficulty getting the
string "&quot;" to appear in the above fragment.
The & sign alway get escaped to &amp; so the line &quot; always appears as
&amp;quot; which is not what I require.
If I put in a " sign then the quote sign actually gets placed in the xml and
does not get escaped to &quot; at all.

any help is producing a fragment in the above format whould be greatly
appreciated.

cheers

martin.

PS. to demonstate what I mean I have included the code below that can be
run from a console application/

Imports System.IO

Imports System.Xml

Module Module1

Sub Main()

Dim xmlDoc As New XmlDocument

Dim xmlElemAddress As XmlNode

Dim root As XmlElement

Try

xmlDoc.LoadXml("<Addresses/>")

xmlElemAddress = xmlDoc.CreateNode(XmlNodeType.Element, "Address", "")

xmlElemAddress.InnerText = "&quot;Somebody's Name&quot; <me@mydomain.com>"

root = xmlDoc.DocumentElement

root.AppendChild(xmlElemAddress)

xmlDoc.Save(Console.Out)

Catch ex As Exception

Console.WriteLine("***ERROR***")

Console.WriteLine(ex.Message.ToString())

Finally

End Try

End Sub

Nov 18 '05 #1
5 3353
Martin,

That's because the escaped entity is &quot; not &qout;

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web
"martin" <ma***************@hotmail.com> wrote in message
news:Oo**************@TK2MSFTNGP12.phx.gbl...
Hi,

I would be extremly grateful for some help on producing an xml fragemt.

The fragment that I wish to produce should look like this

<Addresses>
<Address>&qout;Somebody's Name&quot; &lt;me@mydomain.com&gt;</Address>
</Addresses>

This looks simple enough however I am having great difficulty getting the
string "&quot;" to appear in the above fragment.
The & sign alway get escaped to &amp; so the line &quot; always appears as
&amp;quot; which is not what I require.
If I put in a " sign then the quote sign actually gets placed in the xml and does not get escaped to &quot; at all.

any help is producing a fragment in the above format whould be greatly
appreciated.

cheers

martin.

PS. to demonstate what I mean I have included the code below that can be
run from a console application/

Imports System.IO

Imports System.Xml

Module Module1

Sub Main()

Dim xmlDoc As New XmlDocument

Dim xmlElemAddress As XmlNode

Dim root As XmlElement

Try

xmlDoc.LoadXml("<Addresses/>")

xmlElemAddress = xmlDoc.CreateNode(XmlNodeType.Element, "Address", "")

xmlElemAddress.InnerText = "&quot;Somebody's Name&quot; <me@mydomain.com>"

root = xmlDoc.DocumentElement

root.AppendChild(xmlElemAddress)

xmlDoc.Save(Console.Out)

Catch ex As Exception

Console.WriteLine("***ERROR***")

Console.WriteLine(ex.Message.ToString())

Finally

End Try

End Sub

Nov 18 '05 #2
Try warpping the content in a CDATA block.

"martin" <ma***************@hotmail.com> wrote in message
news:Oo****************@TK2MSFTNGP12.phx.gbl...
Hi,

I would be extremly grateful for some help on producing an xml fragemt.

The fragment that I wish to produce should look like this

<Addresses>
<Address>&qout;Somebody's Name&quot; &lt;me@mydomain.com&gt;</Address>
</Addresses>

This looks simple enough however I am having great difficulty getting the
string "&quot;" to appear in the above fragment.
The & sign alway get escaped to &amp; so the line &quot; always appears as
&amp;quot; which is not what I require.
If I put in a " sign then the quote sign actually gets placed in the xml and does not get escaped to &quot; at all.

any help is producing a fragment in the above format whould be greatly
appreciated.

cheers

martin.

PS. to demonstate what I mean I have included the code below that can be
run from a console application/

Imports System.IO

Imports System.Xml

Module Module1

Sub Main()

Dim xmlDoc As New XmlDocument

Dim xmlElemAddress As XmlNode

Dim root As XmlElement

Try

xmlDoc.LoadXml("<Addresses/>")

xmlElemAddress = xmlDoc.CreateNode(XmlNodeType.Element, "Address", "")

xmlElemAddress.InnerText = "&quot;Somebody's Name&quot; <me@mydomain.com>"

root = xmlDoc.DocumentElement

root.AppendChild(xmlElemAddress)

xmlDoc.Save(Console.Out)

Catch ex As Exception

Console.WriteLine("***ERROR***")

Console.WriteLine(ex.Message.ToString())

Finally

End Try

End Sub

Nov 18 '05 #3
Also, &quot; is not a recognized entity in XML.

"Rick Strahl [MVP]" <ri********@hotmail.com> wrote in message
news:Od**************@TK2MSFTNGP12.phx.gbl...
Martin,

That's because the escaped entity is &quot; not &qout;

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web
"martin" <ma***************@hotmail.com> wrote in message
news:Oo**************@TK2MSFTNGP12.phx.gbl...
Hi,

I would be extremly grateful for some help on producing an xml fragemt.

The fragment that I wish to produce should look like this

<Addresses>
<Address>&qout;Somebody's Name&quot; &lt;me@mydomain.com&gt;</Address> </Addresses>

This looks simple enough however I am having great difficulty getting the string "&quot;" to appear in the above fragment.
The & sign alway get escaped to &amp; so the line &quot; always appears as &amp;quot; which is not what I require.
If I put in a " sign then the quote sign actually gets placed in the xml

and
does not get escaped to &quot; at all.

any help is producing a fragment in the above format whould be greatly
appreciated.

cheers

martin.

PS. to demonstate what I mean I have included the code below that can be run from a console application/

Imports System.IO

Imports System.Xml

Module Module1

Sub Main()

Dim xmlDoc As New XmlDocument

Dim xmlElemAddress As XmlNode

Dim root As XmlElement

Try

xmlDoc.LoadXml("<Addresses/>")

xmlElemAddress = xmlDoc.CreateNode(XmlNodeType.Element, "Address", "")

xmlElemAddress.InnerText = "&quot;Somebody's Name&quot; <me@mydomain.com>"
root = xmlDoc.DocumentElement

root.AppendChild(xmlElemAddress)

xmlDoc.Save(Console.Out)

Catch ex As Exception

Console.WriteLine("***ERROR***")

Console.WriteLine(ex.Message.ToString())

Finally

End Try

End Sub


Nov 18 '05 #4
Hi rick,

this is the xml I want to be written. (I made a slight mistake in my
original posting. -- the first escaped " said &qout; which was incorrect.
the second one said &quot; -- which is correct.) The string I supplied in
the surce code that I supplied are correct.
make a new console application and paste it in, you will see what I mean.

This displays ok in IE however I can't write it out using xmldocument class
because the string &quot; always appears as &amp;quot;

<Addresses>
<Address>&quot;somebody's name&quot; &lt;me@mydomain.com&gt;</Address>
</Addresses>

I am being to think that this is a bug.

any pointers are appreciated

cheers

martin


"Rick Strahl [MVP]" <ri********@hotmail.com> wrote in message
news:Od**************@TK2MSFTNGP12.phx.gbl...
Martin,

That's because the escaped entity is &quot; not &qout;

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web
"martin" <ma***************@hotmail.com> wrote in message
news:Oo**************@TK2MSFTNGP12.phx.gbl...
Hi,

I would be extremly grateful for some help on producing an xml fragemt.

The fragment that I wish to produce should look like this

<Addresses>
<Address>&qout;Somebody's Name&quot; &lt;me@mydomain.com&gt;</Address> </Addresses>

This looks simple enough however I am having great difficulty getting the string "&quot;" to appear in the above fragment.
The & sign alway get escaped to &amp; so the line &quot; always appears as &amp;quot; which is not what I require.
If I put in a " sign then the quote sign actually gets placed in the xml

and
does not get escaped to &quot; at all.

any help is producing a fragment in the above format whould be greatly
appreciated.

cheers

martin.

PS. to demonstate what I mean I have included the code below that can be run from a console application/

Imports System.IO

Imports System.Xml

Module Module1

Sub Main()

Dim xmlDoc As New XmlDocument

Dim xmlElemAddress As XmlNode

Dim root As XmlElement

Try

xmlDoc.LoadXml("<Addresses/>")

xmlElemAddress = xmlDoc.CreateNode(XmlNodeType.Element, "Address", "")

xmlElemAddress.InnerText = "&quot;Somebody's Name&quot; <me@mydomain.com>"
root = xmlDoc.DocumentElement

root.AppendChild(xmlElemAddress)

xmlDoc.Save(Console.Out)

Catch ex As Exception

Console.WriteLine("***ERROR***")

Console.WriteLine(ex.Message.ToString())

Finally

End Try

End Sub


Nov 18 '05 #5
Hi peter
Also, &quot; is not a recognized entity in XML.


thats fair enough, but IE will display the follwoing xml document

<Addresses>
<Address>&quot;somebody's name&quot; &lt;me@mydomain.com&gt;</Address>
</Addresses>

so it seems to me it is valid so I am stumped why I can't write "&quot;"
into the value of an element

also, I may be forced to use a CDATA section, although this is not what I
wanted to do.

cheers

martin.
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DC Gringo | last post by:
I have an image control (that pulls an image off an ESRI map server): <ASP:IMAGE ID="imgZonedCountry" RUNAT="server"></ASP:IMAGE> In the code behind I am setting the ImageURL to a String value...
2
by: Eric Osman | last post by:
Hi, I'm looking for a javascript function that will convert input such as this: <CLUB Code=" into this: &lt;CLUB Code=&quot;
4
by: barney | last post by:
Hello, I' m using .NET System.Xml.XmlDOcument. When I do the following: XmlDocument xml = new XmlDocument(); xml.Load("blah"); .... xml.Save("blub"); I've got the problem that the following...
7
by: DC Gringo | last post by:
I am having a bear of a time with setting a URL query string as a text value in a dropdownlist and Server.URLEncode does not seem to do its job. theFullLink = theLinkPrefix &...
1
by: Lore Leunoeg | last post by:
Hello I want to load a local file into the XmlDocument cache. But when I'm not connected to the internet I get this exeption: "The underlying connection was closed: The remote name could not be...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
13
by: Ragnar | last post by:
Hi, 2 issues left with my tidy-work: 1) Tidy transforms a "&amp;" in the source-xml into a "&" in the tidied version. My XML-Importer cannot handle it 2) in a long <title>-string a wrap is...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.