I tried to format the below XML using xmllint --format xmlfilename with no luck since the file does not have a root node.
As a test I did put a root node and the XML file was formatted successfully.
How can I format this file without a root node?
<connection_param>
<mlc_props_file>
<file_full_path>./fs/public/mxres/mxmlc/mlc_properties.mxres</file_full_path>
</mlc_props_file>
</connection_param>
<login group="CONFIG" password="00100020004100470016" user="CONFIG"/>
You can incorporate that content into a "wrapper" XML file that includes it's content using an external entity reference.
In the example below, it assumes that your content is the fragment.xml file and the "wrapper" XML is in the same directory.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wrapper [
<!ENTITY content SYSTEM "fragment.xml">
]>
<wrapper>
&content;
</wrapper>
Then parse/transform the "wrapper" XML file in order to parse/format the content.
Use tidy:
echo '
<connection_param>
<mlc_props_file>
<file_full_path>./fs/public/mxres/mxmlc/mlc_properties.mxres</file_full_path>
</mlc_props_file>
</connection_param>
<login group="CONFIG" password="00100020004100470016" user="CONFIG"/>
'| tidy -xml -qi
Output:
<connection_param>
<mlc_props_file>
<file_full_path>
./fs/public/mxres/mxmlc/mlc_properties.mxres</file_full_path>
</mlc_props_file>
</connection_param>
<login group="CONFIG" password="00100020004100470016"
user="CONFIG" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With