0

my following string

<Content xmlns="http://www.kkk.com/HTMLMeta">
    <title>Aftersales Marketing Solutions | kkk markit</title>
    <metaDescription>Helps manage key touchpoints during the vehicle ownership life cycle to increase revenue and improve customer loyalty.</metaDescription>
    <primaryKeywords>
        <solrPrimaryNavigatorKeyword>Products and Solutions</solrPrimaryNavigatorKeyword>
        <rank>6</rank>
        <productKeyword>Aftersales Marketing Solutions</productKeyword>
        <businessLine>Automotive</businessLine>
        <primaryIndustry>Banking</primaryIndustry>
        <subIndustry>Coal</subIndustry>
        <rollup>Technology</rollup>
        <secondaryIndustries>Chemicals</secondaryIndustries>
        <secondaryIndustries>Aerospace, Defense &amp; Security</secondaryIndustries>
        <secondaryIndustries>Electronics</secondaryIndustries>
        <pageTypeKeyword>Solution Page</pageTypeKeyword>
        <topicKeyword>Audience Targeting</topicKeyword>
        <topicKeyword>Retail performance</topicKeyword>
        <regionKeyword>Global</regionKeyword>
    </primaryKeywords>
    <dynamicTag>Multiview</dynamicTag>
    <boostDetails>
        <industryValue>Automotive</industryValue>
        <boostValue>-10</boostValue>
    </boostDetails>
</Content>

string 1 to get the string as

<Content xmlns="http://www.kkk.com/HTMLMeta">
    <title>Aftersales Marketing Solutions | kkk markit</title>
    <metaDescription>Helps manage key touchpoints during the vehicle ownership life cycle to increase revenue and improve customer loyalty.</metaDescription>
    <primaryKeywords>
        <solrPrimaryNavigatorKeyword>Products and Solutions</solrPrimaryNavigatorKeyword>
        <rank>6</rank>
        <productKeyword>Aftersales Marketing Solutions</productKeyword>
        <businessLine>Automotive</businessLine>
        <primaryIndustry>Banking</primaryIndustry>

string 2 <subIndustry>Coal</subIndustry>

string 3 <rollup>Technology</rollup>

string 4

    <secondaryIndustries>Chemicals</secondaryIndustries>
        <secondaryIndustries>Aerospace, Defense &amp; Security</secondaryIndustries>
        <secondaryIndustries>Electronics</secondaryIndustries>
        <pageTypeKeyword>Solution Page</pageTypeKeyword>
        <topicKeyword>Audience Targeting</topicKeyword>
        <topicKeyword>Retail performance</topicKeyword>
        <regionKeyword>Global</regionKeyword>
    </primaryKeywords>
    <dynamicTag>Multiview</dynamicTag>
    <boostDetails>
        <industryValue>Automotive</industryValue>
        <boostValue>-10</boostValue>
    </boostDetails>
</Content>

how to split as following string as string 1, string 2 ,string 3 n string 4?

  • 2
    This isn't really a tridion-specific question, so I don't think it belongs here. You may ask it in a more appropriate Stackexchange site. – Harald Hoffelinck Feb 27 '20 at 7:54
3

Without knowing more about what you are trying to do, the simple answer would be: you don't split the XML into strings. You parse it as XML and extract the data that you want.

So, for instance, here's some Powershell code that reads the subIndustry and rollup values:

$xml = [xml]@"
<Content xmlns="http://www.kkk.com/HTMLMeta">
    <title>Aftersales Marketing Solutions | kkk markit</title>
    <metaDescription>Helps manage key touchpoints during the vehicle ownership life cycle to increase revenue and improve customer loyalty.</metaDescription>
    <primaryKeywords>
        <solrPrimaryNavigatorKeyword>Products and Solutions</solrPrimaryNavigatorKeyword>
        <rank>6</rank>
        <productKeyword>Aftersales Marketing Solutions</productKeyword>
        <businessLine>Automotive</businessLine>
        <primaryIndustry>Banking</primaryIndustry>
        <subIndustry>Coal</subIndustry>
        <rollup>Technology</rollup>
        <secondaryIndustries>Chemicals</secondaryIndustries>
        <secondaryIndustries>Aerospace, Defense &amp; Security</secondaryIndustries>
        <secondaryIndustries>Electronics</secondaryIndustries>
        <pageTypeKeyword>Solution Page</pageTypeKeyword>
        <topicKeyword>Audience Targeting</topicKeyword>
        <topicKeyword>Retail performance</topicKeyword>
        <regionKeyword>Global</regionKeyword>
    </primaryKeywords>
    <dynamicTag>Multiview</dynamicTag>
    <boostDetails>
        <industryValue>Automotive</industryValue>
        <boostValue>-10</boostValue>
    </boostDetails>
</Content>
@"

$subIndustries = $xml.Content.primaryKeywords.subIndustry;
$rollup = $xml.Content.primaryKeywords.rollup

Not the answer you're looking for? Browse other questions tagged or ask your own question.