1. Engineering
  2. Computer Science
  3. extract the desired content from the file using quotsed or...

Question: extract the desired content from the file using quotsed or...

Question details

Extract the desired content from the file using "sed or awk or xmlstarlet or some similar tool.
For example in the below xml file we have 2 businessProcesses. and the goal is to extract only one of the businessprocesses from the content with respective to the our input while keeping the format.
Here by default we need the below part
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
************rest of the content should be in between this ****************
</CustomObject>
and now we need to add grab the content in between the
***
<businessProcesses>
        <fullName>Customer Support
***and****
</businessProcesses>

*****************************************File from where the content to be extracted.*****************************************************************

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<businessProcesses>
        <fullName>Customer Support</fullName>
        <description>Use for Customer Support, TDG and Port</description>
        <isActive>true</isActive>
        <values>
            <fullName>Action Item</fullName>
            <default>false</default>
        </values>
        <values>
            <fullName>Solved</fullName>
            <default>false</default>
        </values>
    </businessProcesses>
    <businessProcesses>
        <fullName>Customer Support - Port</fullName>
        <description>Telecom team use only</description>
        <isActive>true</isActive>
        <values>
            <fullName>New</fullName>
            <default>true</default>
        </values>
        <values>
            <fullName>Open</fullName>
            <default>false</default>
        </values>
    </businessProcesses>
</CustomObject>    

*****************************************************************************************************************

*****************************************Required state of the File extracted.*****************************************************************

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<businessProcesses>
        <fullName>Customer Support</fullName>
        <description>Use for Customer Support, TDG and Port</description>
        <isActive>true</isActive>
        <values>
            <fullName>Action Item</fullName>
            <default>false</default>
        </values>
        <values>
            <fullName>Solved</fullName>
            <default>false</default>
        </values>
    </businessProcesses>
</CustomObject>    

*****************************************************************************************************************

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution