XML / DOM-API How to retrieve the integer value of an integer attribute?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<br/>
In my XML File I have the following XML attribute:<br/>
"myIntAttribute"="4711"<br/>
<br/>
I also use a XSD file to validate the XML with DOM. The validation succeeded. "myIntAttribute"="4711"<br/>
is in the XSD specified as decimal (I also tried the following tests with xsd:integer). Here is how I
<br/>
specified its type in the XSD:<br/>
<xsd:attribute name=""myIntAttribute"="4711"" type="xsd:decimal"/><br/>
<br/>
Since validation succeeded and their is a pure digit value ("4711") assigned to "myIntAttribute"<br/>
it must be an integer attribute in the DOM tree.<br/>
<br/>
Herewith I tried to retrieve its value:<br/>
<br/>
VARIANT v_myIntAttribute = spElement -> getAttribute( "myIntAttribute" );<br/>
int i_myIntAttribute = v_myIntAttribute.intVal;<br/>
i_myIntAttribute = v_myIntAttribute.iVal;<br/>
<br/>
Neither .intVal nor .iVal did retrieve the correct value. <br/>
<br/>
<br/>
==> <br/>
<br/>
1. What is the reason for the problem and how can it be fixed?<br/>
<br/>
2. What is the best way in DOM-API to retrieve the integer value of an integer attribute?
<br/>

View the full article
 
Back
Top