Issue with xml validation

Hi, I would like to validate the values of XML parameters but I faced some issues.

            <VHBTV_CD:MediaAttributes>
                <VHBTV_CD:MediaTrack>
                    <VHBTV_CD:SubTitle impairedHearing="true">FRE</VHBTV_CD:SubTitle>
                </VHBTV_CD:MediaTrack>
            </VHBTV_CD:MediaAttributes>

I can only validate the value of an attribute impairedHearing:
pm.expect(jsonObject[‘VHBTV_GRID’][‘ContentLocationTable’][‘TVContentLocation’][‘VHBTV_TV:AVAttributes’] [‘VHBTV_CD:MediaAttributes’][‘VHBTV_CD:MediaTrack’][‘VHBTV_CD:SubTitle’].$[‘impairedHearing’]).to.eql(‘true’);

I try to find out how to validate ‘SubTitle’ itself, so I print it to the console:
console.log(jsonObject[‘VHBTV_GRID’][‘ContentLocationTable’][‘TVContentLocation’][‘VHBTV_TV:AVAttributes’][‘VHBTV_CD:MediaAttributes’][‘VHBTV_CD:MediaTrack’][‘VHBTV_CD:SubTitle’])

  • :arrow_forward:{_: “FRE”, $: {
}}
  1. _: “FRE”

  2. :arrow_forward:$: {
}

  3. impairedHearing: “true”

The issue is related with {: “FRE”, $: {
}} - I have no idea how to deal with ':’

To sum up. I know how to validate the attribute but really don’t know how to validate the language of the subtitle.

Similar situation with genre:
<VHBTV_CD:GenreList>
<VHBTV_CD:Genre genreLabel=“Enfant - sĂ©rie”>BFT-003-005</VHBTV_CD:Genre>
</VHBTV_CD:GenreList>

I am able to validate the genreLabel:
pm.expect(jsonObject[‘VHBTV_GRID’][‘ContentTable’][‘VHBTV_CD:Content’][‘VHBTV_CD:GenreList’] [‘VHBTV_CD:Genre’].$[‘genreLabel’]).to.eql(‘Enfant - sĂ©rie’);

but no idea how to check the value of VHBTV_CD:Genre.

console.log(jsonObject[‘VHBTV_GRID’][‘ContentTable’][‘VHBTV_CD:Content’][‘VHBTV_CD:GenreList’] [‘VHBTV_CD:Genre’])

image

Thank you in advance for any tips :slight_smile:

Hello @Mariamobica , Welcome to the community :partying_face:

var cheerio = require('cheerio');
const $ = cheerio.load(responseBody);
console.log($('VHBTV_CD\\:SubTitle').text());

Please try if this works, you can try to scrape using text() method along with Cheerio.

Also I have added few assertions for Public SOAP API’s, kindly check if you need to :blush:

1 Like

Hello

Thank you for your answer :slight_smile:
It seems to work but still not perfect.

For Subtile the console output looks like that:
“content.subtitleFRE” instead ‘FRE’

and for Genre it looks like that:
"BFT-003-005BFT-003-000 " instead ‘BFT-003-005’

I will try it figure it out.