944,103 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 3091
  • VB.NET RSS
Apr 24th, 2007
0

Multiple Table Reading From An Xml File

Expand Post »
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.



Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
karan_21584 is offline Offline
32 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: weird build issue
Next Thread in VB.NET Forum Timeline: open file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC