/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
Syntax for reading XML Attributes
Fra : S-P-A-R-K


Dato : 27-01-05 13:28

Hi,

I'm trying to get data from XML and insert it into SQL Server.
So far I succeeded and it's ok, but I'm having problem with reading XML
attributes. Here's the sample XML file I have:

<REPORT generated="01/05/2005 22:15:47">
<RANGE from="12/01/2004 00:00:00" to="01/01/2005 00:00:00" />
<NETSERIAL value="426144">
<DEMO>1</DEMO>
<BONUSES>$19.00</BONUSES>
</NETSERIAL>
<NETSERIAL value="660351">
<DEMO>1</DEMO>
<BONUSES>$24.00</BONUSES>
</NETSERIAL>
</REPORT>

Now, I can read the <DEMO> and <BONUSES> using this VB code:

Set objNodes = objXMLDOM.selectNodes("/REPORT/NETSERIAL")

and then I'm inserting it to DB like:

objADORS.Fields("DEMO") =
objBookNode.selectSingleNode("DEMO").nodeTypedValue

objADORS.Fields("BONUSES") =
objBookNode.selectSingleNode("BONUSES").nodeTypedValue

But I don't know the syntax to the <NETSERIAL value="660351">
How do I get the "value" attribute?

Also, How do I combine the 2 levels (REPORT: RANGE/NETSERIAL and
NETSERIAL: DEMO/BONUSES)? I mean what's the nested syntax to read the
calues of them.

Thanks in advance!!!!


 
 
Ryan Dahl (02-02-2005)
Kommentar
Fra : Ryan Dahl


Dato : 02-02-05 04:27

On 27 Jan 2005 04:27:51 -0800, "S-P-A-R-K" <oren.sarig@gmail.com>
wrote:

>
>But I don't know the syntax to the <NETSERIAL value="660351">
>How do I get the "value" attribute?

Hi,

you can use getAttributeNode to fetch attribute values. You might
consider using a different name for your attributes than 'value'.
I'm not sure, but I think it's reserved.

Example:
http://www.devguru.com/Technologies/xmldom/quickref/element_getAttributeNode.html

Regards
Ryan

S-P-A-R-K (07-02-2005)
Kommentar
Fra : S-P-A-R-K


Dato : 07-02-05 15:23

Thanks, I'm using now the XSD and it works fair... :) I'll see if the
GetAttribute works better.

Thanks!!!


Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408914
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste