472,358 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

innerText of xml doc

Hi,

I would like to write the text of an element to an xml doc as that it look
like this

<Address>&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;</Address>

however I can't seen to get the quote marks to come out correctly

the innertext property will change
"<" to &lt;
">" to &gt;

but not " to &quot;

when I write &quot; in the innerText string I get &amp;quot;

I tried to use innerXml instead of innertext but it didn't like that, I
guess because I am not inserting into a cdata section.

my failed attempts are below,

_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText =
"&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;";
<Address>&amp;quot;Marty Jones&amp;quot;
&amp;lt;mj@mydomain.com&amp;gt;</Address>

_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText =
"\"Marty Jones\" <mj@mydomain.com>";
<Address>"Marty Jones" &lt;mj@mydomain.com&gt;</Address>

any help is appreciated

cheers

martin.
Nov 18 '05 #1
6 2298
Xml knows nothing about &quot; so it is unable to process this entity. You
might take a look at the HtmlEncode and HtmlDecode methods which might work
on these entities.

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

I would like to write the text of an element to an xml doc as that it look
like this

<Address>&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;</Address>

however I can't seen to get the quote marks to come out correctly

the innertext property will change
"<" to &lt;
">" to &gt;

but not " to &quot;

when I write &quot; in the innerText string I get &amp;quot;

I tried to use innerXml instead of innertext but it didn't like that, I
guess because I am not inserting into a cdata section.

my failed attempts are below,

_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText =
"&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;";
<Address>&amp;quot;Marty Jones&amp;quot;
&amp;lt;mj@mydomain.com&amp;gt;</Address>

_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText =
"\"Marty Jones\" <mj@mydomain.com>";
<Address>"Marty Jones" &lt;mj@mydomain.com&gt;</Address>

any help is appreciated

cheers

martin.

Nov 18 '05 #2
you can not do it with InnerText.

when you set innerText, it only quotes the chars it needs to. it does not
need to convert " to &quot as quotes are legal between tags. if you want to
control the quoting, then innerHtml is the answer

-- bruce (sqlwork.com)
"martin" <ma***************@hotmail.com> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
Hi,

I would like to write the text of an element to an xml doc as that it look
like this

<Address>&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;</Address>

however I can't seen to get the quote marks to come out correctly

the innertext property will change
"<" to &lt;
">" to &gt;

but not " to &quot;

when I write &quot; in the innerText string I get &amp;quot;

I tried to use innerXml instead of innertext but it didn't like that, I
guess because I am not inserting into a cdata section.

my failed attempts are below,

_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText =
"&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;";
<Address>&amp;quot;Marty Jones&amp;quot;
&amp;lt;mj@mydomain.com&amp;gt;</Address>

_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText =
"\"Marty Jones\" <mj@mydomain.com>";
<Address>"Marty Jones" &lt;mj@mydomain.com&gt;</Address>

any help is appreciated

cheers

martin.

Nov 18 '05 #3
Thats fine,

so why is & being changed to &amp;

and < to &lt; , > to &gt;

but not " to &quot;

all I want is for &quot to appear in the element, the trouble is it always
change a & to &amp;

I'll try HTML encode but I'm not holding out much hope cause they'll still
be a & in the expression.

cheers

martin.
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:uj*************@tk2msftngp13.phx.gbl...
Xml knows nothing about &quot; so it is unable to process this entity. You might take a look at the HtmlEncode and HtmlDecode methods which might work on these entities.

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

I would like to write the text of an element to an xml doc as that it look like this

<Address>&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;</Address>

however I can't seen to get the quote marks to come out correctly

the innertext property will change
"<" to &lt;
">" to &gt;

but not " to &quot;

when I write &quot; in the innerText string I get &amp;quot;

I tried to use innerXml instead of innertext but it didn't like that, I
guess because I am not inserting into a cdata section.

my failed attempts are below,

_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText = "&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;";
<Address>&amp;quot;Marty Jones&amp;quot;
&amp;lt;mj@mydomain.com&amp;gt;</Address>

_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText = "\"Marty Jones\" <mj@mydomain.com>";
<Address>"Marty Jones" &lt;mj@mydomain.com&gt;</Address>

any help is appreciated

cheers

martin.


Nov 18 '05 #4
Hi bruce,

Can you give an exemple of using innerHTML please,

I am using xmldocument class and this is not a member,
I can't see any other innerhtml property, perhaps I am missing something.

cheers

martin.
"bruce barker" <no***********@safeco.com> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
you can not do it with InnerText.

when you set innerText, it only quotes the chars it needs to. it does not
need to convert " to &quot as quotes are legal between tags. if you want to control the quoting, then innerHtml is the answer

-- bruce (sqlwork.com)
"martin" <ma***************@hotmail.com> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
Hi,

I would like to write the text of an element to an xml doc as that it look like this

<Address>&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;</Address>

however I can't seen to get the quote marks to come out correctly

the innertext property will change
"<" to &lt;
">" to &gt;

but not " to &quot;

when I write &quot; in the innerText string I get &amp;quot;

I tried to use innerXml instead of innertext but it didn't like that, I
guess because I am not inserting into a cdata section.

my failed attempts are below,

_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText = "&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;";
<Address>&amp;quot;Marty Jones&amp;quot;
&amp;lt;mj@mydomain.com&amp;gt;</Address>

_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText = "\"Marty Jones\" <mj@mydomain.com>";
<Address>"Marty Jones" &lt;mj@mydomain.com&gt;</Address>

any help is appreciated

cheers

martin.


Nov 18 '05 #5
Try the .xml property.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

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

Can you give an exemple of using innerHTML please,

I am using xmldocument class and this is not a member,
I can't see any other innerhtml property, perhaps I am missing something.

cheers

martin.
"bruce barker" <no***********@safeco.com> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
you can not do it with InnerText.

when you set innerText, it only quotes the chars it needs to. it does not
need to convert " to &quot as quotes are legal between tags. if you want to
control the quoting, then innerHtml is the answer

-- bruce (sqlwork.com)
"martin" <ma***************@hotmail.com> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
Hi,

I would like to write the text of an element to an xml doc as that it

look like this

<Address>&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;</Address>

however I can't seen to get the quote marks to come out correctly

the innertext property will change
"<" to &lt;
">" to &gt;

but not " to &quot;

when I write &quot; in the innerText string I get &amp;quot;

I tried to use innerXml instead of innertext but it didn't like that, I guess because I am not inserting into a cdata section.

my failed attempts are below,
_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText = "&quot;Marty Jones&quot; &lt;mj@mydomain.com&gt;";
<Address>&amp;quot;Marty Jones&amp;quot;
&amp;lt;mj@mydomain.com&amp;gt;</Address>
_message.DocumentElement.SelectSingleNode("Address es/Address").InnerText
= "\"Marty Jones\" <mj@mydomain.com>";
<Address>"Marty Jones" &lt;mj@mydomain.com&gt;</Address>

any help is appreciated

cheers

martin.



Nov 18 '05 #6
Hi Eric,

Thanks for the reply, but where will I find this .xml property.

I am using xmldocument and this does not have an xml property.
It has an innerXML property but this does not meet my needs. ("&quot;" still
get output as "&amp;quot;" and this is not what I require)

I need to have the string "&quot;" appear in <address><address> tags as

<Addresses>
<Address>&qout;Somebody's Name&quot; &lt;me@mydomain.com&gt;</Address>
</Addresses>
if you could show me sample code to produce the above fragment then I would
very much appreciate it. My attempt is below.

cheers

martin.

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@webs>"

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

End Module
Nov 18 '05 #7

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

Similar topics

13
by: Jeff | last post by:
Hi! I'm trying to update a number in a document with the following code. It displays a number, a div block with a minus sign and a div block with a plus sign. When I click the plus sign I want...
2
by: oembuilders | last post by:
Having a bit of trouble figuring out how to get the innerText of a cell other that the one selected. Any help would be apprecated as I am very new to javascript. I got the working example from...
2
by: delraydog | last post by:
I know that innerText is not supported in FireFox and I've found the following code fragment which was originally designed in an HTMLElement prototype for an innerText getter. I do not however want...
6
by: C# newbie | last post by:
Hello group, When I run an XPATH query first as: //*[contains(translate(.,\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\", \"abcdefghijklmnopqrstuvwxyz\")
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
10
by: Angel | last post by:
I want to concat a space in an HTML Control's innerText property. here is a sample code Dim celCreate As New HtmlControls.HtmlTableCell() celCreate.innerText = " TEST" When the page is...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...

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.