473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2360
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.