473,397 Members | 2,068 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,397 software developers and data experts.

Node.text

Hi

Making the switch to .net from VB6, and I noticed that the XMLNode object does not expose a text property. How do I write the text value of an element(vb6 - nod.Text = ....)? BTW I have googled may different combinations, and finding an answer to this is harder than it looks. I promise I am not being lazy

Thanks
Nov 12 '05 #1
3 1906
Have you tried the InnerText property?

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Newbie" <an*******@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
Hi,

Making the switch to .net from VB6, and I noticed that the XMLNode object does not expose a text property. How do I write the text value of an
element(vb6 - nod.Text = ....)? BTW I have googled may different
combinations, and finding an answer to this is harder than it looks. I
promise I am not being lazy.
Thanks

Nov 12 '05 #2

Yes but this returns all text, including any child nodes. I just want the text associated with an element.

<Parent>Element Tex
<Child>blah</Child></Parent

I only want Element Text out of the above. This is what the old node.text property used to provide, at least in MSXML 3.
----- Dare Obasanjo [MSFT] wrote: ----

Have you tried the InnerText property
Nov 12 '05 #3

In your example the XmlElement node named "Parent" has 2 children.
One has NodeType "text" the other has node type "Element".

You are interested in the Value property of the child that has
NodeType==XmlNodeType.Text.

if we change the eg to
<Parent>
first text child
<Child>blah</Child>
second text child
</Parent>
to better represent mixed mode content.

XmlNode "parentNode" is the node whose text value you are interested in .

If you are only interest in "first text child" just use
parentNode.ChildNodes[0].Value.

If you need the entire text content under parentNode - but not the
information from subelements
"first text child
second text child "
you will need to concatenate text values from all its children - like
so:

string value = string.Empty;
foreach(XmlNode child in parentNode.ChildNodes) {
if (child.NodeType == XmlNodeType.Text) {
value += child.Value;
}
}

Thanks,
Tejal.

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

"Newbie" <an*******@discussions.microsoft.com> wrote in message
news:39**********************************@microsof t.com...

Yes but this returns all text, including any child nodes. I just want the text associated with an element.
<Parent>Element Text
<Child>blah</Child></Parent>

I only want Element Text out of the above. This is what the old node.text property used to provide, at least in MSXML 3.0

----- Dare Obasanjo [MSFT] wrote: -----

Have you tried the InnerText property?

Nov 12 '05 #4

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

Similar topics

2
by: Ralf Wahner | last post by:
Dear Masters of XSLT Could I ask you for a clue on the following question? I'd like to use XSLT to transform an XML source file to LaTeX. In the following small example the <para> Element...
1
by: Eric | last post by:
I am trying to figure out a good way to implement a XSLT transformation. Basically my goal is that I want to be able to ouput the following XML in a document: <chart type="pie" width="100"...
4
by: n_o_s_p_a__m | last post by:
My xml doc has many <title></title> and <title> in it, meaning the nodes have no content (although some do). How can I test for this? I tried title (doesn't work) I tried //title (doesn't work)...
2
by: fremenusul | last post by:
I orginally asked this question on friday, and made some progress, but now I am getting an error. What is the type of xmlProductName (check the runtime type in the debugger)? The debug output...
8
by: Ryan Stewart | last post by:
Putting the following code in a page seems to make it go into an infinite loop unless you give it a very simple node to work with. Either that or it's very very slow. I'm somewhat new to this,...
6
by: SHC | last post by:
Hi all, I created an application from the Console Application (.NET) of VC++ .NET 2003, and I did "Build" the application of the attached .cpp file, volcanoes.xml and geology.dtd on my VC++ .NET...
4
by: praveen | last post by:
I have a form with treeview control loaded from xml document,text box, two buttons named "Find" and "FindNext" and my treeview which looks like below. Details |__ policy status |__ created by...
0
by: pavlaras | last post by:
hi all its been a while since i've worked on a VB program and im currently facing difficulties with the following code.I'm trying to create a diagram with nodes which you can manipulate and enter...
8
by: Dylan Parry | last post by:
Hi folks, I have an XML node called "myNode" and it contains: "This is some text" Now I can use the myNode.nodeValue property to get the string of text above. But say myNode contains: ...
0
by: jiing | last post by:
Hi all, I want to use sting(the same as Node.Text) to judge if a node exists in TreeView. I've tried several ways, but seems all failed. could anybody help me? Thanks in advance. //My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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.