Click here to Skip to main content
15,902,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a xml document that I am using for each to loop through parties. I need to get partyID and date of birth. I am getting partyID but date of birth is showing 0001-01-01T00:00:00.

XML Document
XML
<Integration>
	<Case>
		<CaseEvent Date="06/14/2010" ID="252945068">
			<PartyID>9919636</PartyID>
		</CaseEvent>
		<CaseParty ID="9919636">
			<DateOfBirth>04/27/1910</DateOfBirth>
		</CaseParty>
	</Case>
	<IntegrationConditions>
		<IntegrationCondition Word="TAWQ" Description="Inserts">
			<NotificationEvent notificationType="TAWQ" elementKey="252945068">InsertSomething</NotificationEvent>
		</IntegrationCondition>
	</IntegrationConditions>
</Integration>


Expected XML Result
XML
<InsertPWBRorAOS xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="">
	<RelatedParties>
		<CaseParty>
			<DateOfBirth>04/27/1910</DateOfBirth>
			<PartyId>9919636</PartyId>
		</CaseParty>
	</RelatedParties>
</InsertPWBRorAOS>


Wrong result currently
XML
<InsertPWBRorAOS xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="">
	<RelatedParties>
		<CaseParty>
			<DateOfBirth>0001-01-01T00:00:00</DateOfBirth>
			<PartyId>9919636</PartyId>
		</CaseParty>
	</RelatedParties>
</InsertPWBRorAOS>


What I have tried:

My VB.Net code

VB
Public Shared Sub ProcessInsertPWBRorAOS(ByRef aobjXmlInputDoc As System.Xml.XmlDocument, ByVal aobjxmlNotificationEventNode As XmlNode)
Dim objInsertPWBRorAOS As MMGService.InsertPWBRorAOS = New MMGService.InsertPWBRorAOS
Dim objCaseParty As MMGService.CaseParty
Dim objxmlEventPartyIDNode As XmlNode
Dim strEventId As String
strEventId = aobjxmlNotificationEventNode.SelectSingleNode("@elementKey").InnerText

objCaseParty = New MMGService.CaseParty()
'Loop through all PartyIDNodes in CaseEvent with ID equal to NotificationEvent's elementKey 
For Each objxmlEventPartyIDNode In aobjXmlInputDoc.DocumentElement.SelectNodes("Case/CaseEvent[@ID=" + strEventId + "]/PartyID")
	strPartyID = objxmlEventPartyIDNode.InnerText
    objCaseParty.PartyId = strPartyID
    'DateofBirth
    objCaseParty.DateOfBirth = dtmDateOfBirth
    objInsertPWBRorAOS.RelatedParties(i) = objCaseParty
    i += 1
Next
End Sub
Posted
Updated 15-Jul-19 9:28am

1 solution

Looking through the loop I couldn't find where dtmDateOfBirth is defined:
VB
For Each objxmlEventPartyIDNode In aobjXmlInputDoc.DocumentElement.SelectNodes...
   strPartyID = objxmlEventPartyIDNode.InnerText    ' get from original
   objCaseParty.PartyId = strPartyID                ' set in the new

   'DateofBirth
   objCaseParty.DateOfBirth = dtmDateOfBirth        ' set in the new
    i += 1
Next
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900