Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 1st, 2006, 08:05 AM
rascal_mon
Guest
 
Posts: n/a
Default How to read xml to array using javascript

I'm new with XML. Please give me some advice.
I wonder there are any difference between XML that is automatically generated
from ADO and XML file that shows in many textbooks. I found that the formats
are a bit difference. At the begining of the one that is automatically
generated from ADO is usually like this

<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:
C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:
rowset" xmlns:z="#RowsetSchema">
- <s:Schema id="RowsetSchema">
- <s:ElementType name="row" content="eltOnly" rs:updatable="true">


On the other hand, the format that I found from many books and web like this

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test01.xsl"?>
<persons>
<person id="1">
<name>
<prefix>Mr.</prefix>
<fname>Tawan</fname>
<lname>Lakthai</lname>
</name>
<gender>Male</gender>
<birth-date1 January 2551 </birth-date>
<person-id>2471235896341</person-id>
<address>138/42 nakbumrung bangkok 10230</address>
</person>

The later format is easy for me to understand, but the other one is harder.
My point is whether the way to read data from XML file in both types is
different. If yes, what class in java should I use to get data from file.I
understand how to use DOM to read data and write a script using DOM once with
the second format. But the XML file in this assignment is in the first fomat,
so I''m in the dark with it. I have little knowledge about XML and javascript.
I''ve start reseraching for 3 days.
This is my XML file

<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly' rs:updatable='true'>
<s:AttributeType name='StratgID' rs:number='1' rs:nullable='true' rs:
maydefer='true' rs:writeunknown='true'
rs:basetable='Strategy' rs:basecolumn='StratgID' rs:
keycolumn='true'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:
fixedlength='true'/>
</s:AttributeType>
<s:AttributeType name='PerspID' rs:number='2' rs:nullable='true' rs:
maydefer='true' rs:writeunknown='true'
rs:basetable='Strategy' rs:basecolumn='PerspID'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:
fixedlength='true'/>
</s:AttributeType>
<s:AttributeType name='StratgName' rs:number='3' rs:nullable='true' rs:
maydefer='true'
rs:writeunknown='true' rs:basetable='Strategy' rs:
basecolumn='StratgName'>
<s:datatype dt:type='string' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='RightOrder' rs:number='4' rs:nullable='true' rs:
maydefer='true'
rs:writeunknown='true' rs:basetable='Strategy' rs:
basecolumn='RightOrder'>
<s:datatype dt:type='string' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='BottomOrder' rs:number='5' rs:nullable='true' rs:
maydefer='true'
rs:writeunknown='true' rs:basetable='Strategy' rs:
basecolumn='BottomOrder'>
<s:datatype dt:type='string' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='BubbleHeader' rs:number='6' rs:nullable='true' rs:
maydefer='true'
rs:writeunknown='true' rs:basetable='Strategy' rs:
basecolumn='BubbleHeader'>
<s:datatype dt:type='string' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='bgColor' rs:number='7' rs:nullable='true' rs:
maydefer='true' rs:writeunknown='true'
rs:basetable='Strategy' rs:basecolumn='bgColor'>
<s:datatype dt:type='string' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='fgColor' rs:number='8' rs:nullable='true' rs:
maydefer='true' rs:writeunknown='true'
rs:basetable='Strategy' rs:basecolumn='fgColor'>
<s:datatype dt:type='string' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='URL' rs:number='9' rs:nullable='true' rs:
maydefer='true' rs:writeunknown='true'
rs:basetable='Strategy' rs:basecolumn='URL'>
<s:datatype dt:type='string' dt:maxLength='50'/>
</s:AttributeType>
<s:extends type='rs:rowbase'/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row StratgID='0' PerspID='0' StratgName='Organization Change Management'
RightOrder='0' BottomOrder='0' BubbleHeader='Organization Capital'/>
<z:row StratgID='1' PerspID='0' StratgName='Corporate Restructuring'
RightOrder='1' BottomOrder='0'/>
<z:row StratgID='2' PerspID='0' StratgName='HR Development' RightOrder='2'
BottomOrder='0' BubbleHeader='Human Capital'/>
<z:row StratgID='3' PerspID='0' StratgName='Business Intelligent System'
RightOrder='3' BottomOrder='0' BubbleHeader='nation Cappital'/>
<z:row StratgID='4' PerspID='0' StratgName='IT System' RightOrder='4'
BottomOrder='0'/>
<z:row StratgID='5' PerspID='1' StratgName='Service &#x26; Quality
Management' RightOrder='0' BottomOrder='0' BubbleHeader='Operation
Manament'/>
</rs:data>
</xml>

 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles