How to Configure an XML File With SED
Stream Editor is a Unix programming language that parses content such as XML files. You can use the language to create and configure an XML file. You can program the SED language from a Windows computer, but you must debug and run the file on your Unix server. The script creates the XML and checks the XML for any errors.
Instructions
-
-
1
Right-click the SED file you want to edit, and select "Open With." Click "Notepad" to open the SED file in your Windows editor.
-
2
Set the file variable you want to use for the XML file. This is the file in which the XML is stored. Add the following code to the file:
file=myfile.xml
Replace "myfile.xml" with the file name you want to use.
-
-
3
Create the XML nodes. You use the SED "e" switch to write XML tags to the script file. The following code creates an XML node:
sed -e “s/<$2>$node_name<\/$2>/<$2>$nodevalue<\/$2>/g” $1 > $file
Replace "$node_name" with the name you want to give to the node. Replace the value with your own value.
-
4
Configure the file for reader access, so your programs and users can read from the XML file. The following code configures the file for use:
chmod 666 $1
mv $file $1
chmod 444 $fileThe code above changes the file's permissions to "write," so the script can save the changes. The chmod command then changes the permissions to read only, so users cannot change the XML data.
-
1