D
D
demonarxs12018-11-26 15:54:18
JavaScript
demonarxs1, 2018-11-26 15:54:18

How to process manually xml?

Hello!
The task is - it is necessary to format xml. Those. after parsing, the result is displayed in one line. It is necessary to convert it with indents and all sorts of bells and whistles.
Example - Result -
<root><text>123</text></root>

<root>
  <text>
    123
  </text>
</root>

And so I thought, and I myself cannot remember the correct solution to this problem, there are developments, but no more. I understand in general how to do it, but I can not implement it. Those. just get a parser using RegExp. But how to properly process repetitions, occurrences of the same into each other. For example:
<root>
  <text>
    <text>
      123
    </text>
    <text>
      123
      <text>
        123
      </text>
    </text>
  </text>
</root>

Can anyone give a direction (theory), what to read and preferably an example. I thought about the solution for a long time, and somehow my eye was blurred in search to look for. Thanks everyone for the help! (I tried to use a ready-made solution - xml-formatter, it cannot parse my xml. Although it seems that the standard browser DOMParse parses, it does not format it, but gives a string)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2018-11-26
@rPman

google:xml beautify

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question