xml - VB.Net XMLTextReader Keeps Skipping 1st Element in Children -


i'm hoping can me this... reading xml file created server , except when try process file it's skipping 1 of first child elements. , when run test no processing, straight reader , looping through elements, 1st element there. add check see if node element, skips "attachment" element. here's xml:

<reports xmlns=""> <finalreport jobid="335417" lineitemid="400391" filenumber="againtest" propertyid="98765312" ponumber="" propaddress="9255 john street" propcity="fairfax" propstate="va" propzip="22132" orderstatus="delivered" servicename="ext property inspection">     <datacapture>         <!--report saved: 7/1/2011 11:28:43 by: frank-->         <report>             <streetvisible>no</streetvisible>             <vacant>no</vacant>             <salesign>no</salesign>             <rentsign>no</rentsign>             <extcondition>average</extcondition>             <comparedcondition>similar</comparedcondition>             <deferredmaintenance>no</deferredmaintenance>             <underconstruction>no</underconstruction>             <safetyissues>no</safetyissues>             <naturaldisaster>no</naturaldisaster>             <propertylocation>gated</propertylocation>             <propertyuse>triplex</propertyuse>             <nonresidential>no</nonresidential>             <outbuildings>shed</outbuildings>             <garage>no</garage>             <carport>no</carport>             <capacity>2</capacity>             <adversefactors>railroad</adversefactors>             <positivefactors>golfcourse</positivefactors>             <propertytype>condogarden</propertytype>             <homefront>yes</homefront>             <addressphoto>yes</addressphoto>             <streetscene>yes</streetscene>             <anycomments>test comments here...</anycomments>             <fieldrepname>joe inspections</fieldrepname>         </report>     </datacapture>     <attachment imageid="1988" extension="jpg" image_type="img" keyed="0" imagenote="" image="base64" />     <attachment imageid="1990" extension="jpg" image_type="img" keyed="0" imagenote="" image="base64" />     <attachment imageid="1991" extension="jpg" image_type="img" keyed="0" imagenote="" image="base64" />     <attachment imageid="1992" extension="jpg" image_type="img" keyed="0" imagenote="" image="base64" />     <attachment imageid="1993" extension="jpg" image_type="img" keyed="0" imagenote="" image="base64" />     <attachment imageid="1994" extension="jpg" image_type="img" keyed="0" imagenote="" image="base64" /> </finalreport> <pdfreport>base64</pdfreport> 

and here's code i'm using xml - i remove between reader.read(), 1st "attachment" element seems show up. i've tried removing if reader.isstartelement() , still no luck.

using reader xmltextreader = new xmltextreader(xdoc.outerxml, xmlnodetype.document, nothing)                          dim xdata new orderresults_class                          while reader.read()                              if reader.isstartelement()                                 logdebug.append(vbcrlf & "row: " & x & " start: " & reader.isstartelement() & " node type: " & reader.nodetype() & " element: " & reader.name & " >> attributes: " & reader.hasattributes.tostring & " value: " & left(reader.value, 100))                                 ele = reader.name                                  select case ele                                     case "attachment"                                         'logdebug.append(vbcrlf & "row: (" & & ") " & x & " node type: " & reader.nodetype() & " element: " & reader.name & " >> attributes: " & reader.hasattributes.tostring & " value: " & left(reader.value, 100))                                         if reader.hasattributes                                             dim xdataimg new nvmsorderresults_images_class                                              dim myimage() byte = convertimagefrombase64(reader.getattribute("image"))                                              xdataimg                                                 .jobid = checkorder                                                 .imageref = reader.getattribute("imageid")                                                 .filenumber = rs("filenumber").tostring                                                 .imagedescription = reader.getattribute("imagenote")                                                 .imagetype = reader.getattribute("extension")                                                 .imagefile = myimage                                             end                                              dim imgret string = process_orderresults_images(xdataimg)                                             if isnumeric(imgret)                                                 logmsg = "[" & rs("filenumber").tostring & "] photo received: " & imgret                                             else                                                 logmsg = "[" & reader.getattribute("imageid") & "] error processing photo: " & imgret                                             end if                                             applogging.writetablelog(checkorder, logmsg)                                         end if                                      case "finalreport"                                         if reader.hasattributes                                             xdata                                                 .jobid = checkorder                                                 .lineitemid = reader.getattribute("lineitemid")                                                 .filenumber = reader.getattribute("filenumber")                                                 .propertyid = reader.getattribute("propertyid")                                                 .propaddress = reader.getattribute("propaddress")                                                 .propcity = reader.getattribute("propcity")                                                 .propstate = reader.getattribute("propstate")                                                 .propzip = reader.getattribute("propzip")                                                 .service = reader.getattribute("servicename")                                             end                                             'logdebug.append(vbcrlf & "row: (" & & ") " & x & " node type: " & reader.nodetype() & " element: " & reader.name & " >> attributes: " & reader.hasattributes.tostring & " value: " & left(reader.value, 100))                                         end if                                      case "datacapture"                                         xdata.datacollection = reader.readinnerxml                                  end select                             elseif reader.nodetype = xmlnodetype.attribute                                 logdebug.append(vbcrlf & "this attib: " & ele & " start: " & reader.isstartelement() & " node type: " & reader.nodetype() & " element: " & reader.name & " >> attributes: " & reader.hasattributes.tostring & " value: " & left(reader.value, 100))                             elseif reader.nodetype = xmlnodetype.text                                 if ele = "pdfreport"                                     xdata.pdfreport = convertimagefrombase64(reader.value)                                      'save order results ///////////////////////////                                     dim resultret string = process_orderresults(xdata)                                     if isnumeric(resultret)                                         logmsg = "[" & rs("filenumber").tostring & "] job received: " & checkorder                                     else                                         logmsg = "[" & rs("filenumber").tostring & "] error processing results: " & resultret                                     end if                                     applogging.writetablelog(checkorder, logmsg)                                 end if                             end if                              x += 1                          end while                          '// write debugging text ////////////////////////////////////////////                         applogging.writetablelog(checkorder, logdebug.tostring)                          y += 1                     end using 

please let me know if i'm missing something... i'm getting tired of looking @ code ;d thanks!

xmltextreader documented "forward only"; personal interpretation of mean if have attributes x=1 y=2 z=3 , try use getattribute("y") skip on attribute "x" , cannot - attributes not hashlist such foward searched string buffer

so if have 1 attribute missing input dataset (or in wrong order) doesn't mean skip forward next element - haven't tested seems match behaviour of code i've written (and re-written corretcly)

just 2-penneth; may wrong - may heading in right direction not there yet - trying help


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -