xmlNode.InnerText vs. xmlNode.Value

I've loaded the following xml into an XMLDocument object:

<?xml version="1.0" ?>
- <Preferences>
  <Institution>Argh</Institution>
  <Speaker>Chigier, Ben (1234)</Speaker>
  <Worktype>Addendum</Worktype>
  <speakerCode>1234</speakerCode>
</Preferences>

I then try to retrieve the value of the Institution node as follows:

string s = myxmldoc.SelectSingleNode("/Preferences/Institution").Value;

However, s is null after the call.  But if I change the call to the
following, s is what I'd expect: "Argh".

string s = myxmldoc.SelectSingleNode("/Preferences/Institution").InnerText;

Anyone know what's going on?

Thanks...

Dan


0
dan6906 (5)
8/27/2004 8:41:44 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
965 Views

Similar Articles

[PageSpeed] 57

"Dan" <dan@dontspamme.com> wrote in message news:epuPFZHjEHA.2140@TK2MSFTNGP15.phx.gbl...
> string s = myxmldoc.SelectSingleNode("/Preferences/Institution").Value;
>
> However, s is null after the call.  But if I change the call to the
> following, s is what I'd expect: "Argh".
>
> string s = myxmldoc.SelectSingleNode("/Preferences/Institution").InnerText;
>
> Anyone know what's going on?

InnerText goes through the descendant XmlText node(s) of an
XmlNode, and concatenates their value(s) together.  It is the
Value property of the XmlText node(s) that contains text.

There are some questions to ask yourself about XmlElement,
and what the representation of it's Value should be:

     If it had a value, what would it be? LocalName?
     NamespaceURI?  QName?  InnerText?  InnerXml?
     Does an Element whose InnerXml is "<b>Hey</b>"
     have a Value different from one whose InnerXml is
     "Hey," and should it be different?

The Value property of an XmlElement is always null because
XmlElements have no representable value.


Derek Harmon


0
loresayer (274)
8/28/2004 2:13:37 AM

Dan wrote:

> I've loaded the following xml into an XMLDocument object:
> 
> <?xml version="1.0" ?>
> - <Preferences>
>   <Institution>Argh</Institution>
>   <Speaker>Chigier, Ben (1234)</Speaker>
>   <Worktype>Addendum</Worktype>
>   <speakerCode>1234</speakerCode>
> </Preferences>
> 
> I then try to retrieve the value of the Institution node as follows:
> 
> string s = myxmldoc.SelectSingleNode("/Preferences/Institution").Value;
> 
> However, s is null after the call.  But if I change the call to the
> following, s is what I'd expect: "Argh".
> 
> string s = myxmldoc.SelectSingleNode("/Preferences/Institution").InnerText;
> 
> Anyone know what's going on?

Well simply what you expect to be the value of an element is not the 
Value property in the DOM (document object model) that .NET implements. 
In that model there is a base class XmlNode which already has the Value 
property and in its documentation at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlNodeClassValueTopic.asp
details are given what the Value is for the different type of nodes. For 
Element nodes it says
   "A null reference (Nothing). You can use the XmlElement.InnerText or 
XmlElement.InnerXml properties to access the value of the element node."

-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
8/28/2004 12:29:16 PM
It all depends on your NodeType.

This out outlined in the following MSDN article:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxmlnodeclassvaluetopic.asp


If you are going after the Text in a node (type Element or type Text) your 
best bet is to use .InnerText



"Dan" <dan@dontspamme.com> wrote in message 
news:epuPFZHjEHA.2140@TK2MSFTNGP15.phx.gbl...
> I've loaded the following xml into an XMLDocument object:
>
> <?xml version="1.0" ?>
> - <Preferences>
>  <Institution>Argh</Institution>
>  <Speaker>Chigier, Ben (1234)</Speaker>
>  <Worktype>Addendum</Worktype>
>  <speakerCode>1234</speakerCode>
> </Preferences>
>
> I then try to retrieve the value of the Institution node as follows:
>
> string s = myxmldoc.SelectSingleNode("/Preferences/Institution").Value;
>
> However, s is null after the call.  But if I change the call to the
> following, s is what I'd expect: "Argh".
>
> string s = 
> myxmldoc.SelectSingleNode("/Preferences/Institution").InnerText;
>
> Anyone know what's going on?
>
> Thanks...
>
> Dan
>
> 


0
rife (1)
8/29/2004 1:26:28 AM
Reply:

Similar Artilces:

access network shares from exploer vs "network places"
Experts, I got a user who got "access denied" if he opens the folder directly using UNC path. However if he navigates thru "network places" then he has no problem at all! Needless to say, his permissions are set properly on the target folder. He can map to that share fine, but again if he tries to open the driver letter, access denied. Can any one explain why so? What's the difference between accessing a network share from UNC and accessing from "network places"? you probably already do this: You can see more if you switch to normal tree+fil...

entered vs. reconciled
When I download from my bank, it goes into the register as entered. When I download the next time, it re-downloads the same thing sometimes Unfortunately, the program(Mny '04 deluxe) doesn't recognize this as a duplicate download. Does this have something to do with entered vs. reconciled? Usually I'd be able to match it to the proper one but unfortunately its grayed out and cannot select it. Not sure how to undo it or correct it. Michael On 2005-05-09, mpmorin <mpmorin@verizon.net> wrote: > When I download from my bank, it goes into the register as entered. ...

DoCmd.FindRecord...How to use to match a field value
When I open a form, I would like Access to go to a specified record that meets the criteria in a certain field using the 'DoCmd.FindRecord' command in VBA. Unfortunately I have not had much success this way. Can you explain how I can find a record based on the contents of a field on the form. Below is my VBA code. Private Sub Workouts_Click() Dim stfilter As String Dim stFormName As String Dim getdateid As Integer stFormName = "Datelog" getdateid = Me!Workouts.Value stfilter = "[athleteid]=" & Me![Athleteid] DoCmd.Close, acform...

If A1 value is an odd number than b1 =1
If the value in cell A1 is an odd number I want B1 to display number 1 if the value in cell A1 is an even number, I want B1 to display number 0 -- Message posted from http://www.ExcelForum.com One way: B1: =--(MOD(A1,2)=1) In article <eagerowl.15n597@excelforum-nospam.com>, eagerowl <<eagerowl.15n597@excelforum-nospam.com>> wrote: > If the value in cell A1 is an odd number I want B1 to display number 1, > if the value in cell A1 is an even number, I want > B1 to display number 0. Hi Another way: =MOD(A1,2) HTH. Best wishes Harald "eagerowl >&qu...

What does the "$" symbol do to a cell value in a formula.
for example, sumif($c2:$c8,"3",$f2:$f8) It means that if you copy and paste to another cell, the cell references will not change. Jerry "Vernita" wrote: > for example, sumif($c2:$c8,"3",$f2:$f8) Hi! The $ sign makes that reference absolute. In other words: $C2:$C8 and $F2:$F8 Those references are "locked" onto column C and column F. If you were to copy that formula to some other location the column references are absolute and would not change. The same thing applies to the row portion of the reference: C$2:C$8 and F$2:F$8 You can also ma...

todo-list vs calendar
Hi all, I don't know what the differences between todo-list and calendar. Can anyone please explain to me? Thank you in advance. eguy eguy wrote: > Hi all, > > I don't know what the differences between todo-list and calendar. > Can anyone please explain to me? > > Thank you in advance. > eguy Pretend you have a paper calendar. Pretend you have a piece of paper on which you're jotting down tasks and specifying how important they are and when they need to be done, but they're all in a list. They aren't the same in Outlook either. :) You can use bot...

Null values and calculations
I have a null value that appears as a zero in a report as the control is "=nZ([PRS TAT],0)". Yet, I am unable to deduct this zero value from a second value. The field just comes out blank. Is this null zero a true zero or can is not be used for calculations. If not, any suggestions on what I can use instead? Thanks! What is the other calculation? Nz() returns a variant data type so you may need to wrap it in Val() =Val(Nz([PRS TAT],0)) -- Duane Hookom Microsoft Access MVP "Karina M ;)" wrote: > I have a null value that appears as a zero in a report as the cont...

Outlook 2003 pst vs Outlook 2007
Are the pst files in both 2003 and 2007 the same format? Thanks New PST files created in Outlook 2003 and 2007 are both UNICODE by default. -- Russ Valentine [MVP-Outlook] "Gordon" <gbplinux@gmail.com.invalid> wrote in message news:%23CRHYlyhHHA.4064@TK2MSFTNGP02.phx.gbl... > Are the pst files in both 2003 and 2007 the same format? > > Thanks > "Russ Valentine [MVP-Outlook]" <russval@gmail.com> wrote in message news:644197B5-96B6-4F8C-AAE1-A8BDF18AB281@microsoft.com... > New PST files created in Outlook 2003 and 2007 are both UNICODE by...

XmlNode
When an XmlNode method returns an XmlNode, such as a child, is this generated on-the-fly or is it the actual component of the internal tree structure? If the parent is moved in the tree, will the pointer remain valid? I have looked at as much of the structure as I can using .NET Reflector and I think it will, but I want to be sure. I 'm planning to add XmlNodes to the Tag property of TreeNodes in a TreeView to be able to persist changes back to the document and I would like to know if this will take up any more memory than when they are not linked in this way, or if it is better to...

MessageBox difficulties
(I am using VS 2003 .NET with a Windows Form Application project. .NET Framework 1.1) I am trying to use the simple MessageBox::Show(System::String) When I start typing just to see if it is there, I'll type System::Windows::Forms::MessageBox::Show and it all comes up right, but, when I go to compile it tells me: error C2653: 'MessageBoxA' : is not a class or namespace name when I am using it like this: MessageBox::Show((System::String*)"Hello World."); Can somebody let me know what I'm doing wrong and give me the correct way to use it? Thanks ~Chris &qu...

Eliminate 0 values from pivot table
I have a stock detail sheet where I have a line for all stock transactions. Basically they are organized as SKU (stock codes), LOT (lot number) and UNITS (+/- incoming/outgoing). This sheet is summarized in a pivot table. The problem now is than when a certain SKU/LOT is used up, for instance as +10 UNITS and 2 lines showing a usage of a total of -10 UNITS, I do not want this SKU/LOT to occur in the pivot table. Therefore I have considered to add a column that for each line shows for instance an "E" for all lines where the stock as SKU/LOT is empty. Then I could omit these r...

sum a cell value over 75
Please help!! Excel beginner! I need to build a formula that will add any remaining value over 75 in a cell. For example: In cell A1 = 76.5 In cell A2 - I need a formula that will sum anything over 75 and enter 1.5 into cell A2. Thanks in advance for everyone's help!! > For example: > In cell A1 = 76.5 > In cell A2 - I need a formula that will sum anything over 75 and enter 1.5 > into cell A2. Perhaps, as a start .. try in A2: =IF(A1>75,1.5,"") A2 will return 1.5 if A1 contains a number exceeding 75, otherwise A2 will just appear empty ("") -- ...

xmlNode.InnerText vs. xmlNode.Value
I've loaded the following xml into an XMLDocument object: <?xml version="1.0" ?> - <Preferences> <Institution>Argh</Institution> <Speaker>Chigier, Ben (1234)</Speaker> <Worktype>Addendum</Worktype> <speakerCode>1234</speakerCode> </Preferences> I then try to retrieve the value of the Institution node as follows: string s = myxmldoc.SelectSingleNode("/Preferences/Institution").Value; However, s is null after the call. But if I change the call to the following, s is what I'd expect: "A...

AppDateTimeControl default value setting
Hi, I�m trying to do something I think that should be very simple... I just need to bring the AppDateTimeControl Custom Control(that control with the data field, calendar and combobox for time) that holds the Activity's Date and Time of conclusion filled with current date and time (now), when it's an insertion of a new activity. I believe that if I set a default value in the ASPx page /Activities/Phone/edit.aspx (which part of the HTML code is pasted below), it might work... Problem is that I couldn't find any documentation about this control... I know it's not a supported...

How do I split a y axis in order to display extreme values?
I want to split a y axis so that an extreme value can be displayed without making the other other values appear too small in the chart. Hi, Example can be found here, with links to a couple of other explanations. see http://peltiertech.com/Excel/Charts/BrokenYAxis.html Cheers Andy KGB wrote: > I want to split a y axis so that an extreme value can be displayed without > making the other other values appear too small in the chart. -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info ...

How to change the value of a cell when a condition is satisfied, but not otherwise?
I have a small problem. My requirement is as follows: I have two cells and have enabled manual calculation. The first cell loops through the values 1-5 whenever F9 key is pressed. The function for this is -*B9*=IF(B9="1","2",IF(B9="2", "3", IF(B9="3", "4", IF(B9="4", "5", "1"))))- Whenever the value of cell B9 changes from 5 to 1, I need the value of cell C3 to change, but never otherwise. The complication is that cell C3 changes randomly every time B9 changes from value 5 to value 1. Right now, my form...

#value! #2
In a1 I have alink to a cell on another page in the workbook. In b1 the formula a1/100. When I edit the cell ref in a1, b1 returns #value! I don't understand why, and I can't seem to do anything about it. Advice please.tia Exactly what is the linking formula in A1? When you say "edit the cell reference" in A1, what (how) exactly are you doing? -- Regards, RD --------------------------------------------------------------------------- Please keep all correspondence within the NewsGroup, so all may benefit ! ----------------------------------------------------------------...

Deposit vs Check
Can anyone tell me if it is possible to make money put a deposit before a check number on the same date. My payroll goes in on Friday and I write checks that day. Money makes it look like I am negative because money puts checks before deposits. Any help would be great. ewingerter | 2009-05-23 | 7:56:01 PM wrote: >Can anyone tell me if it is possible to make money put a deposit >before a check number on the same date. My payroll goes in on Friday >and I write checks that day. Money makes it look like I am negative >because money puts checks before deposits. Any help would be gr...

Workbench vs. Quantities Query Help
When i am looking at an item in Workbench and I drill into it shouldn't the PAB in Workbench for all sites be equal to the NET in Quantities queries for all sites on that same item? I drill in on any given day and get a different NET. I manually net out the item based on what is showing for PO's, MO's etc. (all demand and supply) and the NET in the Quantities queries window is correct so i am confused about where the number in Workbench is coming from or is there something wrong with the data?? -- Thanks Knavas Yes it should. You might try running a Reconcile on the in...

Dates and cells values
> "beto" <beto@discussions.microsoft.com> wrote in message > news:11F7A8A3-2F0C-404B-806B-97ED577A45B2@microsoft.com... > > How can I get the minimum value from column C for all 8/24/2009 dates in > > Column A? > > > > I tried some index and match functions but still doesn't work. > > > > Column A Column B Column C Column D > > 8/24/2009 12:12:56 AM 113 904 > > 8/24/2009 12:52:56 AM 114 908 > > 8/24/2009 1:32:56 AM 114 907 > > 8/24/2009 2:12:56 AM 112 897 > > 8/24/2009 2:52...

Local Data Group
I'm familiar with creating Local Data Groups in Outlook. With the Offline client, a Local Data Group is automatically created to sync the owners contacts with the offline database. The problem is that when the user clicks the Contacts chekbox from Outlook | CRM | Options | Synchronization Tab it uses the same Local Data Group that is used for the Offline database. The problem is that I want ALL the contacts for all the accounts that I'm the owner for in my offline database. I do NOT want all those contacts im my Outlook contacts as there can be tens of thousands of contacts. In...

Is thr way in Excel to "find" all cells tht cntain spcfic value, .
Sorry about the spelling... had to make it fit. I want to do what "edit - find" does, except print the resulting rows that contain the cells it finds. Is there a way to do this? i.e., search for all rows with "hello" in a cell in column "greeting", say, then hide all the other rows except these. Thank you for your time on this. Hi John check out data / filter / autofilter go to the drop down arrow on the greetings column and choose "hello" to get all your records back, clear the autofilter (data / filter / autofilter) or choose data /filter /...

specify a values for (x) axis in bar chart
how can i specify a values for (x) axis in bar chart in Excel ?? My (y) axis is percent and i need to change the width of bar on (x) axis, but it seems that i can just change the category of it. my project is that for example from 10 to 90m we have 20%, 30% and 50% of three material, from 90 to 200m we have 10% and 90% of two material, etc. I also welcome other suggessions to show this on table. The only 2 charts in the XL domain that allow values for the x-axis are XY Scatter charts and Bubble charts. For other charts, if and only if the x-values are dates, one can set the x-axis...

XPath peformance vs Hash
How does XPath performance compare to accessing a Hashtable structure? I will need to access the same data repeatedly throughout the lifecycle of my application. What factors should I take into consideration? Where do you have your data stored? Are you trying to trade off between storing it in XML and query using XPath vs storing it using a HashTable in code? Hasttable is going to give you better performance, but is not going to be very flexible. Given you have the same data always, Hashtable is the better approach though. "Ben" <benjaminsleek@gmail.com> wrote in messag...

VS 2010 is cheaper
A while ago, we were bemoaning the loss of VS 2010 Standard, and the price of VS 2008 Professional (presumably with a free upgrade to 2010) was something like $1500 USD. Now there are new VS 2010 prices. http://www.eweek.com/c/a/Application-Development/Microsoft-Offers-Deals-for-Visual-Studio-2010-Retail-Customers-550413/ Basically if you have VS 2005/2008 Standard, you can get VS2010 Standard for $299. And even if you are totally new to VS, you can get VS2010 Professional for $799 and upgrade for $549. And Professional now comes with MSDN Essentials. So the prices are muc...