User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 392,087 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,929 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser:
Views: 1564 | Replies: 0
Reply
Join Date: Mar 2007
Posts: 30
Reputation: karan_21584 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
karan_21584 karan_21584 is offline Offline
Light Poster

Question Multiple Table Reading From An Xml File

  #1  
Apr 24th, 2007
hi, i m trying to read the xml file which contain two database table values..... when i m doing this, the 1st table value has read. but the second table value cannot be fetched....
my code is :
Dim xmldoc As XmlDocument
Dim xmlschfile As String
xmlschfile = "D:\woxml\wodet_sch.xml"
Dim fs As FileStream = New FileStream(xmlschfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
xmldoc = New XmlDocument
xmldoc.Load(fs)
Dim xmlnode As XmlNodeList = xmldoc.GetElementsByTagName("xs:element")
Dim i As Integer = 1
Dim k As Integer = 2
Dim str, str2 As String
'Dim tabval(xmlnode.Count) As String
Dim xmlattrc1 As XmlAttributeCollection = xmlnode(i).Attributes
'tabval(0) = xmlattrc1(0).Value
While i < xmlnode.Count
Dim xmlattrc As XmlAttributeCollection = xmlnode(i).Attributes
System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1)
If i >= 3 Then
'tabval(k - 1) = xmlattrc(0).Value
'tabval(k - 1) = tabval(k - 1) + " " + xmlnode(k).Attributes.Item(1).Value
str = xmlattrc(0).Value
str2 = xmlnode(k).Attributes.Item(1).Value
Console.WriteLine(str)
Console.WriteLine(str2)
k = k + 1
End If
End While
Console.ReadLine()
End Sub

the xml file content is :

<?xml version="1.0" standalone="yes" ?>
- <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element name="comwohed">
- <xs:complexType>
- <xs:sequence>
<xs:element name="wono" type="xs:string" minOccurs="0" />

<xs:element name="wo_date" type="xs:dateTime" minOccurs="0" />

<xs:element name="wo_fr_dt" type="xs:dateTime" minOccurs="0" />

<xs:element name="wo_to_dt" type="xs:dateTime" minOccurs="0" />

<xs:element name="vend_code" type="xs:string" minOccurs="0" />

<xs:element name="job_code" type="xs:string" minOccurs="0" />

<xs:element name="name_of_wk" type="xs:string" minOccurs="0" />

<xs:element name="payment_tr" type="xs:string" minOccurs="0" />

<xs:element name="wo_type" type="xs:string" minOccurs="0" />

<xs:element name="m_p_sup" type="xs:string" minOccurs="0" />

<xs:element name="no_of_itms" type="xs:decimal" minOccurs="0" />

<xs:element name="net_amount" type="xs:decimal" minOccurs="0" />

<xs:element name="amend_no" type="xs:decimal" minOccurs="0" />

<xs:element name="amend_dt" type="xs:dateTime" minOccurs="0" />

<xs:element name="run_fin" type="xs:string" minOccurs="0" />

<xs:element name="rete_pr" type="xs:decimal" minOccurs="0" />

<xs:element name="itax_pr" type="xs:decimal" minOccurs="0" />

<xs:element name="admn_pr" type="xs:decimal" minOccurs="0" />

<xs:element name="womc_pr" type="xs:decimal" minOccurs="0" />

<xs:element name="stax_pr" type="xs:decimal" minOccurs="0" />

<xs:element name="oth1_pr" type="xs:decimal" minOccurs="0" />

<xs:element name="oth2_pr" type="xs:decimal" minOccurs="0" />

<xs:element name="oth1_cd" type="xs:string" minOccurs="0" />

<xs:element name="oth2_cd" type="xs:string" minOccurs="0" />

<xs:element name="term_cond" type="xs:string" minOccurs="0" />

<xs:element name="wo_status" type="xs:string" minOccurs="0" />

<xs:element name="last_bill" type="xs:decimal" minOccurs="0" />

<xs:element name="mes_stat" type="xs:string" minOccurs="0" />

<xs:element name="wo_aprvl" type="xs:string" minOccurs="0" />

<xs:element name="spl_agency" type="xs:string" minOccurs="0" />

<xs:element name="updatedby" type="xs:string" minOccurs="0" />

<xs:element name="updatedon" type="xs:dateTime" minOccurs="0" />

<xs:element name="aprv_id" type="xs:string" minOccurs="0" />

<xs:element name="close_id" type="xs:string" minOccurs="0" />

<xs:element name="trantag" type="xs:string" minOccurs="0" />

<xs:element name="backup_log" type="xs:decimal" minOccurs="0" />

<xs:element name="stagetag" type="xs:string" minOccurs="0" />

<xs:element name="arec_pr" type="xs:decimal" minOccurs="0" />

<xs:element name="aprv_by" type="xs:string" minOccurs="0" />

<xs:element name="curr_code" type="xs:string" minOccurs="0" />

<xs:element name="retn_code" type="xs:string" minOccurs="0" />

<xs:element name="tds_code" type="xs:string" minOccurs="0" />

<xs:element name="st_code" type="xs:string" minOccurs="0" />

<xs:element name="tds_key" type="xs:decimal" minOccurs="0" />

<xs:element name="st_key" type="xs:decimal" minOccurs="0" />

<xs:element name="pay_centre" type="xs:string" minOccurs="0" />

<xs:element name="paid_at" type="xs:string" minOccurs="0" />

<xs:element name="pono" type="xs:string" minOccurs="0" />

<xs:element name="last_bl_dt" type="xs:dateTime" minOccurs="0" />

<xs:element name="st_cat" type="xs:string" minOccurs="0" />

<xs:element name="it_cat" type="xs:string" minOccurs="0" />

<xs:element name="po_val" type="xs:decimal" minOccurs="0" />

<xs:element name="l_itst_tag" type="xs:string" minOccurs="0" />

<xs:element name="l_it_c_no" type="xs:string" minOccurs="0" />

<xs:element name="l_it_per" type="xs:decimal" minOccurs="0" />

<xs:element name="l_it_fr_dt" type="xs:dateTime" minOccurs="0" />

<xs:element name="l_it_to_dt" type="xs:dateTime" minOccurs="0" />

<xs:element name="l_st_c_no" type="xs:string" minOccurs="0" />

<xs:element name="l_st_per" type="xs:decimal" minOccurs="0" />

<xs:element name="l_st_fr_dt" type="xs:dateTime" minOccurs="0" />

<xs:element name="l_st_to_dt" type="xs:dateTime" minOccurs="0" />

<xs:element name="account_id" type="xs:decimal" minOccurs="0" />

<xs:element name="acct_upddt" type="xs:dateTime" minOccurs="0" />

<xs:element name="aprv_dt" type="xs:dateTime" minOccurs="0" />

<xs:element name="wo_version" type="xs:string" minOccurs="0" />

<xs:element name="wo_for" type="xs:string" minOccurs="0" />

<xs:element name="wo_cat" type="xs:string" minOccurs="0" />

<xs:element name="cess_per" type="xs:decimal" minOccurs="0" />

<xs:element name="hpc_apr_by" type="xs:string" minOccurs="0" />

<xs:element name="hpc_apr_dt" type="xs:dateTime" minOccurs="0" />

<xs:element name="plan_vend" type="xs:string" minOccurs="0" />

<xs:element name="vat_per" type="xs:decimal" minOccurs="0" />

<xs:element name="serv_per" type="xs:decimal" minOccurs="0" />

<xs:element name="wk_add_des" type="xs:string" minOccurs="0" />

<xs:element name="sub_machno" type="xs:decimal" minOccurs="0" />

<xs:element name="eip_aprreq" type="xs:string" minOccurs="0" />

<xs:element name="eip_canres" type="xs:string" minOccurs="0" />

<xs:element name="nc_woamt" type="xs:decimal" minOccurs="0" />

<xs:element name="nc_cf_val" type="xs:decimal" minOccurs="0" />

<xs:element name="nc_cf_dt" type="xs:dateTime" minOccurs="0" />

<xs:element name="o_m_p_sup" type="xs:string" minOccurs="0" />

</xs:sequence>


</xs:complexType>


</xs:element>


- <xs:element name="wodet">
- <xs:complexType>
- <xs:sequence>
<xs:element name="job_code" type="xs:string" minOccurs="0" />

<xs:element name="wono" type="xs:string" minOccurs="0" />

<xs:element name="acti_code" type="xs:string" minOccurs="0" />

<xs:element name="quantity" type="xs:decimal" minOccurs="0" />

<xs:element name="acct_cd" type="xs:string" minOccurs="0" />

<xs:element name="amend_no" type="xs:decimal" minOccurs="0" />

<xs:element name="rate" type="xs:decimal" minOccurs="0" />

<xs:element name="value" type="xs:decimal" minOccurs="0" />

<xs:element name="item_code" type="xs:string" minOccurs="0" />

<xs:element name="qty_flag" type="xs:string" minOccurs="0" />

<xs:element name="asset_code" type="xs:string" minOccurs="0" />

<xs:element name="meas_id" type="xs:decimal" minOccurs="0" />

<xs:element name="group_code" type="xs:string" minOccurs="0" />

</xs:sequence>


</xs:complexType>


</xs:element>


</xs:choice>


</xs:complexType>


</xs:element>


</xs:schema>

when i executing the above "Object reference not set to an instance of an object." error is occuring at the line " str2 = xmlnode(k).Attributes.Item(1).Value"... help me plz...thanks in advance.



AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

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

 

DaniWeb VB.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 12:33 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC