473,466 Members | 1,286 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Check InnterText value in XMLDocument

132 New Member
Hi there.

I have written an application which returns an XmlDocument which has several nodes. What I am looking to do is display the InnerText value of one of these specific nodes but I cannot get this to work at all.

I have tried Googling this but none of the results so far have worked, so any help would be most appreciated please?

In my code, I create an XmlDocument and assign it to a returned result from a method which makes a call to an external process:

e.g.

Expand|Select|Wrap|Line Numbers
  1.  
  2. XmlDocument xmlDoc = SomeExternalWebService("123");           
  3.  
  4. txtXMLString.Text = anInnterText_value_returned_xml;
  5.  
  6.  
Hence I am looking to find out how to parse the InnerText value which will only occur for one of the nodes, so this node is uniquely named.

Ultimately I want to test this InnerText value within an If-Condition and take action accordingly but any help will be so much appreciated.

Thank you.

Mark
Sep 7 '11 #1
7 1664
Dormilich
8,658 Recognized Expert Moderator Expert
if your programming language supports the DOM, you can use its Node.textContent or CharacterData.data properties.
Sep 7 '11 #2
E11esar
132 New Member
Hi there. I am coding in C# but will look up what you have suggested. I am also thinking that maybe Linq to XML might help me, but this is all new to me.
Thank you.
Sep 7 '11 #3
Dormilich
8,658 Recognized Expert Moderator Expert
ultimately, you would have to look up in the C# documentation, how XML data are handled (be it through DOM or otherwise)
Sep 7 '11 #4
E11esar
132 New Member
Yes I have done that but all the suggestions have not worked for me. I thought this would take about an hour to accomplish, so far I have worked on this for over a month now!

It really is getting silly as it can't be this hard to achieve.

Thank you.
Sep 7 '11 #5
Dormilich
8,658 Recognized Expert Moderator Expert
Moving to C# forum, maybe the guys here have a better idea than me.
Sep 7 '11 #6
GaryTexmo
1,501 Recognized Expert Top Contributor
First off, maybe give your spelling a check. I'm pretty sure you're after the InnerText object, but you've written InnterText more than once. Can you please confirm?

Anyway, I'm pretty sure you mean the InnerText object on an XmlNode object. An XmlDocument object has a property called DocumentElement, which is the root node for your XML structure. You can start your processing there and then go through all the XmlNodes in DocumentElement's ChildNodes property.

At any point, you can then inspect the InnerText property.

I'm not entirely sure if that answers your question. If it doesn't, can you please clarify?
Sep 7 '11 #7
E11esar
132 New Member
Hi there. Yup I meant InnerText - just been a long night and day with this, thank you.

I have finally cracked the solution with this. One of those slap palm on forehead moments as I had literally written the answer several times in my code.

I wasn't quoting the correct web uri within my xml namespace definition so my code was somewhat suspect.

I've taken a step back and followed the example as highlighted via MSDN:

http://msdn.microsoft.com/en-us/library/h0hw012b.aspx

i.e.
Expand|Select|Wrap|Line Numbers
  1.  
  2. XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
  3.  nsmgr.AddNamespace("ab", "http://www.lucernepublishing.com");
  4.  XmlNode book = doc.SelectSingleNode("//ab:book", nsmgr);
  5.  
So all working now.

Thank you for your help.

M :)
Sep 7 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Stephen Miller | last post by:
I have a page with many, dynamically generated combo boxes and I want to check all of them, before I add a unique value to specific combo. What would be the best way to work through the document...
5
by: DJTB | last post by:
Dear Group, I'd like to check if a value is defined in an enum. Example: ------------------------------------------------------ typedef enum { A_VALUE = 1,
0
by: Mark Sandfox | last post by:
What I need to do is simple in any other code, but I am having a problem finding the correct syntax for this function. I have the following: <form Runat="Server">
3
by: NH | last post by:
How can I check the value of a textbox has no more than 2 decimal places? I already check that the value is numeric, but how do I check that it is not 0.223 or .022 etc. I only want to allow up...
3
by: GS | last post by:
Hi, I have following value which I need to check wether it's null or not. Issue is that StartPrice itself can be a null and checking (myItem.StartPrice.Value == null) do not produce true. How do...
0
by: phil | last post by:
Hi, The aspx file contains a datasource and a gridview. The (only) field is a boolean type (true/false). Now, when the value of the field is 'true' something must happen (e.g....
1
by: leem | last post by:
Hi Can some body guide me how to Link the check box value to Text Box. below is the problem . I've two options in the Check Box method where I've make a Option group for that to select the one...
4
by: Mahbub Hasan | last post by:
There r 3 checkbox . .. first check box value = 2 , second check box value = 4 , third check box value = 6 . now if i check 1st one it will send 2 to the database field, if check the first and...
5
by: =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?= | last post by:
Hello. I am reading a value from a table and trying to determine if that value exists in a list of values associated with a dropdownlist. If so, I select the value, otherwise, I don't. I haven't...
1
by: imtmub | last post by:
Hi All, I have Database developed in VB6.0 and Backend SQL2000. In that application i have few check boxes and there value is (1/0 , yes/no). According to the selection the value stored in sql...
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
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...
1
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.