I've done a small amount of xml parsing with VB.NET but every time I
do it, it seems the xml is formatted somehow different that the time
before, and presents me with a new challenge. Today is just such a
day.
Given the following XML document, I'm attempting to look and see if
"DetailLine", which there are multiples, has a value of "Admin Fee"
for the BilledCode. If so then within that DetailLine node I need to
extract the UnAllocAmtBilled.
<dataroot>
<CBill>
<DetailLines>
<DetailLine>
<BillMode />
<BillPeriodFrom>2008-11-30T00:00:00</BillPeriodFrom>
<BillPeriodTo>0001-01-01T00:00:00</BillPeriodTo>
<ChgEffectiveDate>0001-01-01T00:00:00</ChgEffectiveDate>
<ChgReasonCode />
<CoveredLives />
<CustComments />
<EePostTaxBilled>0.00</EePostTaxBilled>
<EePreTaxBilled>0.00</EePreTaxBilled>
<EePostTaxRecon>0.00</EePostTaxRecon>
<EePreTaxRecon>0.00</EePreTaxRecon>
<ElectionAmt>1,039.92</ElectionAmt>
<ErAmtBilled>0.00</ErAmtBilled>
<ErAmtRecon>0.00</ErAmtRecon>
<Product>
<BilledCode>Admin Fee</BilledCode>
</Product>
<UnAllocAmtBilled>3.00</UnAllocAmtBilled>
<UnAllocAmtRecon>3.00</UnAllocAmtRecon>
</DetailLine>
<DetailLine>
</DetailLine>
</CBill>
</dataroot>
I've barely scratched the surface on this coding. All I have so far
is:
Dim oDoc As XmlDocument = New XmlDocument()
Dim nFeeNodeList as XmlNodeList
Dim nFeeNode as XmlNode
oDoc.LoadXML([an object that is loading the xml])
nFeeNodeList = oDoc.SelectNodes("/dataroot/CBill/DetailLines/
DetailLine")
For Each nFeeNode in nFeeNodeList
' And this is where i get stuck. I've seen some example using
ChildNodes with an index but I'd rather specify the childnode by name
' if possible. i.e something like nFeeNode.ChildNodes.Node("./
Product/BilledCode").Value
' or something magical like that
Next