0

for the following XML below I want to find the patientInfo tag and find out what is in between the < and "patientInfo>" using Java. I think the bes way is to use a matcher. So I wrote code as the following (assume that above String is in variable k). I would then use m.group(0) or m.group(1). The thought being, once I do this, I can get contained information.

    Pattern p = Pattern.compile("<.*:patientInfo>");
    Matcher m = p.matcher(k);
    System.out.println(m.matches()); 

but matches is false. I guess I don't have the RE quite right. Any suggestions? (All sensitive information has been replaced)

(more stuff above)
<ns3:insuredInfo>
  <ns3:insuredId>ID12345678</ns3:insuredId>
  <ns3:insuredSecondaryInd>N</ns3:insuredSecondaryInd>
  <ns3:firstName>GEORGE</ns3:firstName>
  <ns3:lastName>WASHINGTON</ns3:lastName>
  <ns3:gender>M</ns3:gender>
</ns3:insuredInfo>
<ns3:patientInfo>
      <ns3:firstName>CATHY</ns3:firstName>
      <ns3:middleInitial>N</ns3:middleInitial>
      <ns3:lastName>LASTLY</ns3:lastName>
      <ns3:gender>F</ns3:gender>
      <ns3:birthDate>08/13/2006</ns3:birthDate>
      <ns3:addressLine1>123 MAIN ST</ns3:addressLine1>
      <ns3:cityName>ANY TOWN</ns3:cityName>
      <ns3:stateName>NY</ns3:stateName>
      <ns3:zipCode>11418</ns3:zipCode>
      <ns3:patientAccountNumber>12345678xyz</ns3:patientAccountNumber>
 </ns3:patientInfo>
   (more stuff underneath)
Tony
  • 1,127
  • 1
  • 18
  • 29

0 Answers0