私は誰かがこれを手伝ってくれることを願っています...私はサーバーから作成されたXMLファイルを読んでいます。常に最初の子要素の1つをスキップします。そして、処理を行わずにテストを実行すると、まっすぐなリーダーで要素をループして、最初の要素がそこにあります。しかし、ノードがElementかどうかを確認するためのチェックを追加するとすぐに、「Attachment」要素はスキップされます。ここに私のXMLです:VB.Net XMLTextReaderは子供の第1要素をスキップし続ける
<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 AM 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 some 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>
、ここでは、私はXMLを取得するために使用しているコードです - 私はreader.Read()
間のすべてを削除し、次に、この第一、「添付ファイル」要素が現れているようです。私もIf reader.IsStartElement()
を削除しようとしましたが、まだ運がありません。
Using reader As XmlTextReader = New XmlTextReader(xdoc.OuterXml, XmlNodeType.Document, Nothing)
Dim xData As New OrderResults_Class
While reader.Read()
If reader.IsStartElement() Then
LogDebug.Append(vbCrLf & "Row: " & x & " Is 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: (" & a & ") " & x & " Node Type: " & reader.NodeType() & " Element: " & reader.Name & " >> Attributes: " & reader.HasAttributes.ToString & " Value: " & Left(reader.Value, 100))
If reader.HasAttributes Then
Dim xDataImg As New NVMSOrderResults_Images_Class
Dim myImage() As Byte = ConvertImageFromBase64(reader.GetAttribute("Image"))
With xDataImg
.JobID = CheckOrder
.ImageRef = reader.GetAttribute("imageID")
.FileNumber = rs("FileNumber").ToString
.ImageDescription = reader.GetAttribute("ImageNote")
.ImageType = reader.GetAttribute("extension")
.ImageFile = myImage
End With
Dim ImgRet As String = Process_OrderResults_Images(xDataImg)
If IsNumeric(ImgRet) Then
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 Then
With 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 With
'LogDebug.Append(vbCrLf & "Row: (" & i & ") " & 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 Then
LogDebug.Append(vbCrLf & "This is an Attib: " & ele & " Is Start: " & reader.IsStartElement() & " Node Type: " & reader.NodeType() & " Element: " & reader.Name & " >> Attributes: " & reader.HasAttributes.ToString & " Value: " & Left(reader.Value, 100))
ElseIf reader.NodeType = XmlNodeType.Text Then
If ele = "PDFReport" Then
xData.PDFReport = ConvertImageFromBase64(reader.Value)
'Save Order Results ///////////////////////////
Dim ResultRet As String = Process_OrderResults(xData)
If IsNumeric(ResultRet) Then
LogMsg = "[" & rs("FileNumber").ToString & "] Job Successfully 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
私はこのコードを見ての疲れてる...何かが欠けている場合は私に知らせてください; D ありがとう!