How to get XmlNode "value"? Concept?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a simple XML file which is loaded into a XmlDocument, xDom. What the
number 1 after each element, for example <PA>, is called in XML concept? What
kind of C# function can be used to get this number? by GetValue? Thanks

David

<PA>1
<ST>1
<SE>1
<IM>1</IM>
<IM>2</IM>
</SE>
<SE>2
<IM>1</IM>
<IM>2</IM>
<IM>3</IM>
</SE>
</ST>
</PA>
 
david said:
I have a simple XML file which is loaded into a XmlDocument, xDom. What the
number 1 after each element, for example <PA>, is called in XML concept? What
kind of C# function can be used to get this number? by GetValue? Thanks
<PA>1
<ST>1
<SE>1
<IM>1</IM>
<IM>2</IM>
</SE>
<SE>2
<IM>1</IM>
<IM>2</IM>
<IM>3</IM>
</SE>
</ST>
</PA>

The PA element has mixed content of text child nodes and element child
nodes (ST element). That structure above, while being allowed, is not a
good choice to structure and access the data. Either make that 1 value
an attribute e.g.
<PA attribute="1">
<ST attribute="1">
<SE attribute="1">
<IM>1</IM>
and so on or use an additional child element e.g.
<PA>
<VALUE>1</VALUE>
<ST>
<VALUE>1</VALUE>

With your original structure you could access
xmlDocumentInstance.DocumentElement.FirstChild.NodeValue
to access that 1 inside the PA element but you will get a string with
the digit and the white space after it e.g.
@"1
"
 
Back
Top