XmlNode.Value

Can anyone from M$ or anyone else for that matter explain to me the
reasoning behind the intended usage for this property? I was quite surprised
to find that this property may be null depending on the XmlNodeType. If one
imagines a scenario where some hapless programmer adds a new node to an
XML-document, e.g.

childNode = doc.CreateNode (XmlNodeType.Element, "foo", "");

and then decides to set the *value* (the "string" between <nodename> and
</nodename>) of this node, one could easily imagine that our programmer
would look for a method or property called setValue/setNodeValue or just
Value. Unfortunately, setting this value will cause an exception if the node
is an XmlElement. Instead our programmer is supposed to use a property
called 'InnetText'! How intuitive is that? IMHO the designers of the XmlNode
class has got this wrong, especially with respect to the use of the terms
Value (for something that clearly isn't) and InnerText and the former's more
or less hidden dependency on XmlNodeType.

Opinions, anyone?

Eirik M.


0
Eirik
9/25/2003 1:27:55 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
682 Views

Similar Articles

[PageSpeed] 6

"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:upUe602gDHA.2260@TK2MSFTNGP10.phx.gbl...
> Eirik M. wrote:
>
> > Can anyone from M$ or anyone else for that matter explain to me the
> > reasoning behind the intended usage for this property? I was quite
surprised
> > to find that this property may be null depending on the XmlNodeType. If
one
> > imagines a scenario where some hapless programmer adds a new node to an
> > XML-document, e.g.
> >
> > childNode = doc.CreateNode (XmlNodeType.Element, "foo", "");
> >
> > and then decides to set the *value* (the "string" between <nodename> and
> > </nodename>) of this node, one could easily imagine that our programmer
> > would look for a method or property called setValue/setNodeValue or just
> > Value. Unfortunately, setting this value will cause an exception if the
node
> > is an XmlElement. Instead our programmer is supposed to use a property
> > called 'InnetText'! How intuitive is that?
>
> Well, when working with DOM for years, it looks intuitive enough :)

:-)

> Otherwise - I'm agree that's not too clear for a newbie.
>
> As a matter of fact it's how DOM standard was designed - elements and some
> other nodes have no value.
> See
>
http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core.html#ID-1950641247

Ok. I was afraid this was the case. You see Oleg, I've just written a Java
client to access a set of web-services and I used GLUE as the Xml library
and there I can do node.getNodeValue () and node.setNodeValue ("some
value"). For elements I can call element.SetInt for Ints, element.SetText
("") for string values, etc. So I sort of expected something similar in
..Net.

>
> > IMHO the designers of the XmlNode
> > class has got this wrong, especially with respect to the use of the
terms
> > Value (for something that clearly isn't) and InnerText and the former's
more
> > or less hidden dependency on XmlNodeType.
>
> They just implemented W3C DOM standard.

I see that now.

>Send your objections to W3C instead.

Too late. However, nothing stops implementers from abstracting the spec to
make it more useable :-)

Eirik M.

>
> -- 
> Oleg Tkachenko
> http://www.tkachenko.com/blog
> Multiconn Technologies, Israel
>


0
Eirik
9/25/2003 2:46:24 PM
Eirik M. wrote:

> Can anyone from M$ or anyone else for that matter explain to me the
> reasoning behind the intended usage for this property? I was quite surprised
> to find that this property may be null depending on the XmlNodeType. If one
> imagines a scenario where some hapless programmer adds a new node to an
> XML-document, e.g.
> 
> childNode = doc.CreateNode (XmlNodeType.Element, "foo", "");
> 
> and then decides to set the *value* (the "string" between <nodename> and
> </nodename>) of this node, one could easily imagine that our programmer
> would look for a method or property called setValue/setNodeValue or just
> Value. Unfortunately, setting this value will cause an exception if the node
> is an XmlElement. Instead our programmer is supposed to use a property
> called 'InnetText'! How intuitive is that?

Well, when working with DOM for years, it looks intuitive enough :)
Otherwise - I'm agree that's not too clear for a newbie.

As a matter of fact it's how DOM standard was designed - elements and some 
other nodes have no value.
See 
http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core.html#ID-1950641247

> IMHO the designers of the XmlNode
> class has got this wrong, especially with respect to the use of the terms
> Value (for something that clearly isn't) and InnerText and the former's more
> or less hidden dependency on XmlNodeType.

They just implemented W3C DOM standard. Send your objections to W3C instead.

-- 
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

0
oleg7603 (294)
9/25/2003 3:04:38 PM
Reply:

Similar Artilces:

return value from access into excel based on criteria or content
I have two unique challenges that I need help figuring out: 1. I have an access database of names Example: Name: Van Gogh, Vincent I have an excel sheet that has Name but may have incorrect spelling or variances. Example: Name: VanGogh, Vincent Vincent Van Gogh Van Go Vincent (etc) I would like to find a way to pull in the correct value for name and title from access into excel based on exact match, close match or keyword. 2. I would also like to do the same for name and title combination. Example- access database has Name and Title Name: Van Gogh Title: Starry Night the excel sheet...

value of value of a variable.
I tried searching, but no use! I have a Const NameA = "BLA BLA" I have a variable NameB Value of NameB is NameA. How do i get the text "BLA BLA" from NameB variable Is there anyway to do that? something like,, VALUE(NameB) Thanks & Regards Joe Hi Dim NameB as String NameB =3D NameA in a cell you could have range("A1").Value =3D NameB would now have content "BLA BLA" regards Paul On May 21, 12:35=A0pm, Joe <joe.varghese.j...@gmail.com> wrote: > I tried searching, but no use! > > I have a Const Name...

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...

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...

How do I get an automatic reminder with a certain cell value?
Is there a way to receive a pop-up comment or text box when a certain thing is typed into a cell? For example, each time I type "new instrument", I want a reminder to pop-up like a comment would that says "Call Property Accounting". Is there a function like this in Excel? If you have a list of terms, maybe you can use an adjacent helper cell and use a nice =vlookup() formula to show your message. Debra Dalgleish has some instructions at: http://www.contextures.com/xlFunctions02.html Aubri wrote: > > Is there a way to receive a pop-up comment or text box when a ...

Code to Query SQL Server with a parameter value (entered into an Input Box), and have that value also display in a selected cell on a worksheet
I'm wondering how BEST to accomplish this. I have a EXCEL workbook which populates data to, and retrieves data from SQL Server. I currently have VBA code which effectively sends the data from the EXCEL worksheet to SQL Server tables -- no problem with this. I currently have VBA code which effectively retrieves data from SQL Server and displays that data back into the worksheet -- no problem with this either. I'm currently using a Command Button (on-click event) and the code below to query SQL Server to determine the Max Version Number and add 1 to that value. This value is t...

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...

#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 ! ----------------------------------------------------------------...

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...

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 ...

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 to get the XML path of an XmlNode?
How can I get the full XML path (as string) of a specific XmlNode ? -- Thanks Sharon Sharon wrote: > How can I get the full XML path (as string) of a specific XmlNode ? What is "the full XML Path" of a node, do you have any definition for that? Some XML editors can assist you constructing or maybe even generating an XPath expression. -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ Lets say I have the following XML file: <?xml version="1.0" encoding="utf.8"?> <System Name = "System"> <Parameters> <T1&...

Need help with PASTE_SPECIAL-VALUES
Is there a formula that allows you to copy an array of cells an paste-values these cells into a different array automatically? If no please read below... When importing large tables of numbers from the internet, I tried to d everything I knew to do to get Excel to recognize them as number (formatted the cells as numbers, multiplied the cells by 1, and =i cell>0,cell,"0" but none of these change its format. After importing data from the internet, it does not allow me to sor the cells unless I copy/paste-values it first. Maybe there is anothe way to also get around this; do yo...

Excel
hi, anyone to solve my problem ? I have an Abacus that contain : Cell B1 to R1 contain (CABLE SIZE): 4mm, 6mm, 10mm, 16mm, 25mm, 35mm, 50mm, 70mm, 95mm, 120mm, 150mm, 185mm, 2x70mm, 2x95mm, 2x120mm, 2x150mm and 2x185mm Cell A2 to A20 contain (POWER): 0.4kw, 0.75kw, 1.5kw, 2.2kw, 3.7kw, 5.5kw, 7.5kw, 11kw, 15kw, 18.5kw, 22kw, 30kw, 37kw, 45kw, 55kw, 89kw, 90kw, 110kw, 132kw Cell B2 to R20 contain a number (Maximum Length). How can I find the "CABLE SIZE" (Cell B1 to R1) if I have a POWER and a LENGTH? PS, the LENGTH I have his not a value in the table, so I want to take the a...

Duplicate and Null values
Here's the breakdown: I am working with a separate Internet database tool that allows me to export information. I chose the categories I needed, exported the info, and imported into Excel, to then import into Access (2007). Some of the data contains multiple contacts per one record. For example, record #123 could have 3 contacts. In anyone of those contacts another field could, or could not have been chosen. A specific example: Record ID: Date Created: Name: Ethnicity: 4340458 12/12/2006 Tom Smith 4340458 12/12/2006 Tom Smith 4340458 12/12/2006 Tom Smi...

Last Value in a Column when Value <> 0
Hi, can someone provide me a formula that populates a cell with the last value in a column that does not = 0? Below is an example 3 6 7 0 0 0 The goal is to populate a cell with the value of 7. I am currently using the below formula that populates the last value of a column: =INDEX('Retirement Total'!B:B,MATCH(9.99999999999999E+307,'Retirement Total'!B:B)) I do not however know how to change this to not populate the last value when it is zero. Your help is appreciated. Assuming you want the last *numeric* value that <>0. Try something like this: =LOOKUP(1E100,1/'...

Diagram with constant values in the background
I am working with MSExcel 2003. From a table I create a graph, no matter the kind of graph. Say that the scale is 0 to 100 and the number of values is 20. That is: X: 1, 2, ..., 20 Y: 10, 56, ..., 2 In the backgound I need to display some constant values, for example to show min and max acceptable values. This can be defined by a single value for each line. That is: Min: 30 Max: 90 How can I define to the chart these values, without having to add more columns (min, max, ...) to the table and fill in them, and to refer to them in the chart? Thank you. tax In short, you can't. You need to t...

How do I calculate escalation rates using dates and a set value
If I have a projected that needs to be escalated using start and completion dates by a certain percentage per year, how do I write the formula. For example if my project starts May 26, 2010 and lasts until may 26 2014 I want to add escalation to midpoint at 4% per year. ...

Replacing values in a report
Hey Newsgroup, although I think my problem is simple, I can't figure out how to solve it: I got a database collecting folders. Every folder has a certain status (1 = In Archive, 2 = Borrowed, 3 = Destroyed) stored in my table. When showing the report, I want to show the text, not only the number, so I have to replace those. How do I do that? And why does the report, when eg some folder has the id 620 only show 62 and how do I correct this (with the format function?) thanks a lot Thorben Grosser Create a small table, with fields such as: FolderStatusID Number primary key...

Converting negative date values
I imported some data from a delimited file where one of the columns represented date data. When importing the data to Excel, I requested from the program to assign a date data type to the date column and completed the data import. Unfortunately, the import process assigned a general data type to the date column and the values are represented like in 20040605 for June 5, 2004. Excel sees 20040605 as a number but when trying to format the cell to a date, I get a string of ####### indicating that the date value is a negative date. Any suggestions on how to convert this data into a date ...

XmlSerialization to XmlNode
I have a schema that I load into classes that mirror the schema using the XmlSerialization. The schema contains an xsd:Any that I load into 'Extra' as follows: [XmlElement(ElementName="Extra")] public XmlNode Extra { get { return extra;} set { extra = value;}} However, if I have: <Something> <Extra> <a>something</a> <b>another thing</b> </Extra> </Something> I would expect Extra to contain an XmlNode of : <Extra> <a>something</a> <b>another thing</b> <...

display text box border only when text box value <>0
For a text box in a report, I want a border when the value in the box <>0. Can't figure out how?! -- Alan A simple solution would be to use Conditional Formatting to change the color of the text box. It's on the format menu, in report design view, when you select the text box (or on the Design tab of the ribbon in A2007.) If you do want to programmatically change the border, use the Format event of the section containing the text box, to set its BorderColor and BorderStyle. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenb...

Sum based on range values
I need to sum a column A, but only if values in an adjacent column B>0. Therefore the example below should sum to 10 (only including the first 3 rows). A B 7 5 0 4 3 9 0 0 0 0 0 0 8 0 0 0 0 0 Ideally this should be a formula in a cell, not a macro. Any ideas? It doesn't sound complicated, but I can't get my head round it. TIA Ian Thanks Julie. I knew it had to be straightforward. Just a case of knowing which function to use. Ian "JulieD" <JulieD@hctsReMoVeThIs.net.au> wrote in message news:%23$anRGw$EHA.3836@tk2msftngp13.phx.gbl... > Hi > > us...

value types and automaticaly initialized
Hi! The variable myInstanceInt in class Foo below is automaticaly initialized to 0 because the implicit constructor that is called. class Foo { int myInstanceInt; public void MyMethod() { int myLocalInt; Console.WriteLine(myLocalInt); } } The local variable myLocalInt in method MyMethod is not automaticaly initialized becuase if this valiable is not exlicit initialized I get compile error when I try to write it's value as in this statement Console.WriteLine(myLocalInt); I mean when instance value type like myInstanceInt above is auto...

How do I run a macro when a value occurs in a cell
I want to run a macro when a value appears in a cell. How can this be accomplished? Hi! This is a trivial example but you can build on it: Private Sub Worksheet_Change(ByVal Target As Range) If Range("D3") = 36 Then Range("D3").Interior.ColorIndex = 6 Else Range("D3").Interior.ColorIndex = 2 End If End Sub Put =A3*3 in D3 Try values such as 12, 10 in A3 Al -- Alf ----------------------------------------------------------------------- AlfD's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=478 View this thread: http://www.excelforu...