Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
format an xml file with no root node in linux

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"/>
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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.

over 4 years ago · Santiago Trujillo Report

0

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" />
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!