Best way to get correct information from a long string

Hi there!

I'm trying to extract a single-line string from a long API response. (the response I'm trying to extract text from is at the bottom of this post.

This line of text will always be preceded by:
<TitleDetail>
      <TitleType>01</TitleType>
      <TitleElement>
        <TitleElementLevel>01</TitleElementLevel>
        <TitleText>

and end with </TitleText>

In the following response, the line I'm trying to extract would be: "Capitool Leuke uitstapjes in Nederland en Vlaanderen"

I've been trying stuff out with Regex_Search, but so far haven't been succesful, and perhaps there's a better way to do this in OutSystems. What would be the best way to go about this?

Thanks in advance,
Marleen


<Product>
  <RecordReference>9789000307456</RecordReference>
  <NotificationType>04</NotificationType>
  <ProductIdentifier>
    <ProductIDType>03</ProductIDType>
    <IDValue>9789000307456</IDValue>
  </ProductIdentifier>
  <DescriptiveDetail>
    <ProductComposition>00</ProductComposition>
    <ProductForm>BC</ProductForm>
    <Measure>
      <MeasureType>01</MeasureType>
      <Measurement>218</Measurement>
      <MeasureUnitCode>mm</MeasureUnitCode>
    </Measure>
    <Measure>
      <MeasureType>02</MeasureType>
      <Measurement>123</Measurement>
      <MeasureUnitCode>mm</MeasureUnitCode>
    </Measure>
    <Measure>
      <MeasureType>03</MeasureType>
      <Measurement>7</Measurement>
      <MeasureUnitCode>mm</MeasureUnitCode>
    </Measure>
    <Measure>
      <MeasureType>08</MeasureType>
      <Measurement>163</Measurement>
      <MeasureUnitCode>gr</MeasureUnitCode>
    </Measure>
    <ProductClassification>
      <ProductClassificationType>06</ProductClassificationType>
      <ProductClassificationCode>105</ProductClassificationCode>
    </ProductClassification>
    <ProductClassification>
      <ProductClassificationType>07</ProductClassificationType>
      <ProductClassificationCode>BK_ALG</ProductClassificationCode>
      <Percent>100</Percent>
    </ProductClassification>
    <Collection>
      <CollectionType>10</CollectionType>
      <TitleDetail>
        <TitleType>01</TitleType>
        <TitleElement>
          <TitleElementLevel>02</TitleElementLevel>
          <TitleText>Capitool reisgidsen</TitleText>
        </TitleElement>
      </TitleDetail>
    </Collection>
    <TitleDetail>
      <TitleType>01</TitleType>
      <TitleElement>
        <TitleElementLevel>01</TitleElementLevel>
        <TitleText>Capitool Leuke uitstapjes in Nederland en Vlaanderen</TitleText>
      </TitleElement>
    </TitleDetail>
    <TitleDetail>
      <TitleType>05</TitleType>
      <TitleElement>
        <TitleElementLevel>01</TitleElementLevel>
        <TitleText>CAPITOOL LEUKE UITSTAPJES IN NED EN VLAANDEREN</TitleText>
      </TitleElement>
    </TitleDetail>
    <TitleDetail>
      <TitleType>10</TitleType>
      <TitleElement>
        <TitleElementLevel>01</TitleElementLevel>
        <TitleText>*CAPITOOL LEUKE UITSTAPJES IN NED EN VLAANDEREN</TitleText>
      </TitleElement>
    </TitleDetail>
    <TitleDetail>
      <TitleType>11</TitleType>
      <TitleElement>
        <TitleElementLevel>01</TitleElementLevel>
        <TitleText>Capitool Leuke uitstapjes in Nederland en Vlaanderen</TitleText>
      </TitleElement>
    </TitleDetail>
    <NoContributor/>
    <EditionStatement>Heruitgave</EditionStatement>
    <Language>
      <LanguageRole>01</LanguageRole>
      <LanguageCode>dut</LanguageCode>
    </Language>
    <Extent>
      <ExtentType>00</ExtentType>
      <ExtentValue>80</ExtentValue>
      <ExtentUnit>03</ExtentUnit>
    </Extent>
    <Illustrated>02</Illustrated>
    <Subject>
      <MainSubject/>
      <SubjectSchemeIdentifier>32</SubjectSchemeIdentifier>
      <SubjectCode>511</SubjectCode>
    </Subject>
  </DescriptiveDetail>
  <CollateralDetail>
    <TextContent>
      <TextType>05</TextType>
      <ContentAudience>03</ContentAudience>
      <Text datestamp="20150910T120913">Zin in een leuk uitstapje, maar je hebt geen idee waarheen? In Leuke uitstapjes in Nederland en Vlaanderen vind je 38 suggesties voor een leuk dagje uit in Nederland en Vlaanderen. Wil je met z'n tweeën, met het gezin of met vrienden naar een museum, een spannend attractiepark, of naar de dierentuin? Deze gids staat vol met verrassende ideeën voor jong en oud. </Text>
    </TextContent>
    <SupportingResource>
      <ResourceContentType>01</ResourceContentType>
      <ContentAudience>03</ContentAudience>
      <ResourceMode>03</ResourceMode>
      <ResourceVersion>
        <ResourceForm>02</ResourceForm>
        <ResourceVersionFeature>
          <ResourceVersionFeatureType>01</ResourceVersionFeatureType>
          <FeatureValue>D502</FeatureValue>
        </ResourceVersionFeature>
        <ResourceVersionFeature>
          <ResourceVersionFeatureType>02</ResourceVersionFeatureType>
          <FeatureValue>800</FeatureValue>
        </ResourceVersionFeature>
        <ResourceVersionFeature>
          <ResourceVersionFeatureType>03</ResourceVersionFeatureType>
          <FeatureValue>460</FeatureValue>
        </ResourceVersionFeature>
        <ResourceVersionFeature>
          <ResourceVersionFeatureType>04</ResourceVersionFeatureType>
          <FeatureValue>9789000307456_covr.jpg</FeatureValue>
        </ResourceVersionFeature>
        <ResourceVersionFeature>
          <ResourceVersionFeatureType>05</ResourceVersionFeatureType>
          <FeatureValue>.0774</FeatureValue>
        </ResourceVersionFeature>
        https://cbonlinerhcbot.boekhuis.nl/pls/cover/p_get_cover_fe?p_hash=D55202816D24DD595F20D460994E26BE
        <ContentDate>
          <ContentDateRole>01</ContentDateRole>
          <Date dateformat="00">20150910</Date>
        </ContentDate>
      </ResourceVersion>
    </SupportingResource>
  </CollateralDetail>
  <PublishingDetail>
    <Imprint>
      <ImprintName>Van Reemst</ImprintName>
    </Imprint>
    <Publisher>
      <PublishingRole>01</PublishingRole>
      <PublisherIdentifier>
        <PublisherIDType>10</PublisherIDType>
        <IDValue>6903129</IDValue>
      </PublisherIdentifier>
      <PublisherName>CB Test EAN's voor webservices</PublisherName>
    </Publisher>
    <PublishingStatus>04</PublishingStatus>
    <PublishingDate>
      <PublishingDateRole>01</PublishingDateRole>
      <Date dateformat="00">20120319</Date>
    </PublishingDate>
  </PublishingDetail>
  <RelatedMaterial/>
  <ProductSupply>
    <SupplyDetail>
      <Supplier>
        <SupplierRole>00</SupplierRole>
        <SupplierIdentifier>
          <SupplierIDType>13</SupplierIDType>
          <IDValue>ISBISB</IDValue>
        </SupplierIdentifier>
        <SupplierName>CB</SupplierName>
      </Supplier>
      <ProductAvailability>21</ProductAvailability>
      <SupplyDate>
        <SupplyDateRole>08</SupplyDateRole>
        <Date dateformat="00">20120314</Date>
      </SupplyDate>
      <Price>
        <PriceType>04</PriceType>
        <PriceCondition>
          <PriceConditionType>00</PriceConditionType>
        </PriceCondition>
        <DiscountCoded>
          <DiscountCodeType>03</DiscountCodeType>
          <DiscountCode>A</DiscountCode>
        </DiscountCoded>
        <PriceAmount>7.99</PriceAmount>
        <Tax>
          <TaxRateCode>R</TaxRateCode>
          <TaxRatePercent>6.00</TaxRatePercent>
          <TaxableAmount>7.54</TaxableAmount>
        </Tax>
        <CurrencyCode>EUR</CurrencyCode>
        <PriceDate>
          <PriceDateRole>14</PriceDateRole>
          <Date dateformat="00">20120414</Date>
        </PriceDate>
      </Price>
      <Price>
        <PriceType>01</PriceType>
        <PriceCondition>
          <PriceConditionType>00</PriceConditionType>
        </PriceCondition>
        <DiscountCoded>
          <DiscountCodeType>03</DiscountCodeType>
          <DiscountCode>A</DiscountCode>
        </DiscountCoded>
        <PriceAmount>7.54</PriceAmount>
        <Tax>
          <TaxRateCode>R</TaxRateCode>
          <TaxRatePercent>6.00</TaxRatePercent>
          <TaxableAmount>7.54</TaxableAmount>
        </Tax>
        <CurrencyCode>EUR</CurrencyCode>
        <PriceDate>
          <PriceDateRole>14</PriceDateRole>
          <Date dateformat="00">20120414</Date>
        </PriceDate>
      </Price>
    </SupplyDetail>
  </ProductSupply>
</Product>


Hi Marleen, maybe you can first map the xml to a structure with this component:

https://www.outsystems.com/forge/component-overview/153/xml-records


Then you can do with the structure what you want/need to do..


Hope it helps.

Hi Marleen,

As an alternative to what Freek is suggestion you could consider to use Xpath.

There is a success document available on how to parse XML files using Xpath expressions in OutSystems.

Regards,

Daniel

Hi Marleen,

If mapping to a structure doesn't work, you can manually parse the XML response by using the actions from the XML extension. 

Kind regards,

Wouter.


Solution

Hi Marleen,

adding to what has already be said, I gave the xml extension with xpath a try, see attached oml.

Dorine

Solution

Thanks so much guys!

Mapping the XML response by using actions from the XML extension seems like the best option.
I ran into some issues with the API that we'll resolve later, but so far so good.

I'll mark this question as resolved :)

Dorine Boudry wrote:

Hi Marleen,

adding to what has already be said, I gave the xml extension with xpath a try, see attached oml.

Dorine

Dorine, this is wonderful! Thank you so much!