0
public void RemoveprimaryKey()
    {
        string domainName = System.Configuration.ConfigurationSettings.AppSettings["domainName"];
        string userName = System.Configuration.ConfigurationSettings.AppSettings["userName"];
        string passowrd = System.Configuration.ConfigurationSettings.AppSettings["passowrd"];
        timestamp = DateTime.Now.ToString("dd:MM:yy h:mm:ss tt").Replace(":", "_").Replace(" ", "");
        string content = string.Empty;
        string primaryIndustry = "primaryIndustry";
        client = CoreServiceClientFactory.GetClient();
        string[] tcmList = System.IO.File.ReadAllLines(Environment.CurrentDirectory + "\\" + "PrimaryIndustry.txt");
        string[] tcmSaved = System.IO.File.ReadAllLines(Environment.CurrentDirectory + "\\log1\\" + "componentListsaved.txt");
        foreach (var tcmid in tcmList.Except(tcmSaved))
        {
            ComponentData ComponentContent = null;
            try
            {
                ComponentContent = client.Read(tcmid, new ReadOptions()) as ComponentData;
            }
            catch (Exception ex)
            {
                ComponentContent = null;
            }
            if (ComponentContent != null && ComponentContent.Content.Contains(primaryIndustry))
            {
                content = ComponentContent.Content;
                //content = content.Replace(subIndustry, secondaryIndustries);
                //content = content.Replace(primaryIndustry, null);
                // string str2 = content.Substring(content.IndexOf("<primaryIndustry"), content.IndexOf("</primaryIndustry>") - content.IndexOf("<primaryIndustry") + 18);

                //string result2 = str2.Remove(content.IndexOf("<primaryIndustry"), content.IndexOf("</primaryIndustry>"));
                string str1 = content.Substring(0, content.IndexOf("<primaryIndustry"));
                string str4 = content.Substring(0,content.IndexOf("</primaryIndustry"));
                content = str1 +  str4;
                ComponentContent.Content = content;
            }

here i need to remove Primary Industry tagged Keyword

1
string str1= content.Remove(content.IndexOf("<primaryIndustry"), content.IndexOf("</primaryIndustry>") - content.IndexOf("<primaryIndustry") + 18);
string str = str1;
ComponentContent.Content = str;

I tried on my own its working now i could able to remove keyword

This might help some one.

Thanks

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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