const data = [
{
urlset: {
$: { xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9' },
url: [
{ loc: ['https://profile.co/'], changefreq: ['daily'] },
{ loc: ['https://clutch.co/accounting'], changefreq: ['daily'] },
{
loc: ['https://clutch.co/accounting/abilene'],
changefreq: ['daily'],
},
{
loc: ['https://profile.co/accounting/akron'],
changefreq: ['daily'],
},
],
},
},
{
urlset: {
$: { xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9' },
url: [
{ loc: ['https://clutch.co/'], changefreq: ['daily'] },
{ loc: ['https://clutch.co/accounting'], changefreq: ['daily'] },
{
loc: ['https://profile.co/accounting/abilene'],
changefreq: ['daily'],
},
{
loc: ['https://profile.co/accounting/akron'],
changefreq: ['daily'],
},
],
},
},
];
I have this kind of data and I want to filter the data based on a condition and that is in htat I want to filter all object’s url array by the loc property whre there is profile in the link.
Desired Output
[
{
urlset: {
$: { xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9' },
url: [
{ loc: ['https://profile.co/'], changefreq: ['daily'] },
{
loc: ['https://profile.co/accounting/akron'],
changefreq: ['daily'],
},
],
},
},
{
urlset: {
$: { xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9' },
url: [
{
loc: ['https://profile.co/accounting/abilene'],
changefreq: ['daily'],
},
{
loc: ['https://profile.co/accounting/akron'],
changefreq: ['daily'],
},
],
},
},
];
Thanks!