Hello!
I am trying to write a method to parse some information from an XML file. I’m new to XML and have spent the past week reading all the topics on the forum and what I could find on google.
I’m having issues reading the value of child nodes when using a namespace. My file is healthcare related so I can’t show the full file but I will show some snippets and what I have done so far.
Here is a sample of the XML response (right now I just pasted part of the file into Servoy but the real file will come from a webservice)
var testXML =
<EligibilityReponse xmlns="https://api.test.com/draft/1/">
<Payer>
<Name>Payers Name</Name>
<Identification>00000</Identification>
</Payer>
<Provider>
<LastName>Doe</LastName>
<FirstName>John</FirstName>
<NPI>123456789</NPI>
</Provider>
<Subscriber>
<LastName>LnameTest</LastName>
<FirstName></FirstName>
<MemberID></MemberID>
<GroupNumber>
<ID>groupid</ID>
<Description></Description>
</GroupNumber>
<PlanNumber></PlanNumber>
<Address>
<Street></Street>
<City></City>
<State></State>
<PostalCode></PostalCode>
</Address>
<DOB>--</DOB>
<Gender></Gender>
<EligibilityBenefitInformation>
<Type>
C
<Description>Deductible</Description>
</Type>
<CoverageLevel>
FAM
<Description>Family</Description>
</CoverageLevel>
<ServiceType>
30
<Description>Health Benefit Plan Coverage</Description>
</ServiceType>
<PlanCoverageDescription>PPO PLAN 59</PlanCoverageDescription>
<MonetaryAmount>15000</MonetaryAmount>
<ConditionResponse>
N
<Description>Out of network</Description>
</ConditionResponse>
<DateTime>
<Qualifier>
348
<Description>Benefit Begin</Description>
</Qualifier>
<PeriodFormatQualifier>
D8
<Description>Date Expressed in Format CCYYMMDD</Description>
</PeriodFormatQualifier>
<Period>20090101</Period>
</DateTime>
<Message>PER FAMILY</Message>
</EligibilityBenefitInformation>
</Subscriber>
</EligibilityReponse>
By following the examples I found I am able to pull a value by doing this:
application.output(testXML.Subscriber.EligibilityBenefitInformation.Type.Code)
and I get the output of ‘C’
This only works however if I delete the ’ xmlns=“https://api.test.com/draft/1/”’ out of the file.
If I save the namespace to a variable and do the following:
var ns = testXML.namespace()
application.output(testXML..ns::Subscriber)
I get the entire block from Subscriber which I expected. I can’t figure out though how to go below that level.
If anyone could point me in the right direction I would greatly appreciate it!
Thanks,
Bryant