Search code examples
xmlvb.netlinq-to-xmlxml-database

Unable to retrieve data from XML using linq to xml with multiple namespaces


I am unable to retrieve the data from XML looks like its I might be missing

The data I need to retrieve looks like this:

 <rs:data>
    <z:row billno='B0033582' billdtm='2012-05-21T22:57:02' tab_room='        ' waiter='SUP   ' pax='1' discount='.00000000'
    billdisamt='.00000000'   />

i am unable to retrive the data because of this <z:row vs <row

Namespace details

<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'>

If i change this to row i can retrieve the data, is it possible to retrieve the row information when the row starts with <z:row z: is a i guess the namespace reference as given here xmlns:z='#RowsetSchema' .

Please help me way to get the data out


Solution

  • the answer was quite simple,

    Just make these small changes, add these at the top

    Imports <xmlns:rs='urn:schemas-microsoft-com:rowset'>
    Imports <xmlns:z='#RowsetSchema'>
    

    This should contain your namespace information generally available in the first few rows of the xml file

    and then for the element which is referred with the namespace just add z: referred about <z:row>

    I could not find a solution in spite of searching all over, hopefully others would find this useful.