D
D
Djasar2021-02-23 19:16:43
C++ / C#
Djasar, 2021-02-23 19:16:43

How to make correct output in a file?

There is a code that cuts out the information I need. (But not correctly)

string[] lines = File.ReadAllLines("C:\\1.xml");
            IEnumerable<string> xmlLines = lines.Where(x => x.Contains("<Types>"));
            HashSet<string> xmlLinesHashSet = new HashSet<string>(xmlLines);
            string[] sorted = xmlLinesHashSet.ToArray();
            File.WriteAllLines ("C:\\2.xml", sorted);

produces the correct result, but not quite. I want it to also remove the "<"type">" tags and save the values ​​in one line.
View source:
<Types>1526 1528765 </Types>
      <Types>1526 152025 </Types>
      <Types>1572 152761 152662 </Types>

And I want the conclusion like this
1526 1528765 1526 152025 1572 152761 152662
Either just everything in a column (much better)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
d-stream, 2021-02-23
@d-stream

Learn what xml is and how to work with it.

A
Alexander Ananiev, 2021-02-23
@SaNNy32

https://metanit.com/sharp/tutorial/16.2.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question