E
E
Evgeny Ivanov2020-07-21 13:05:52
XML
Evgeny Ivanov, 2020-07-21 13:05:52

What are xml files?

In my work, I have come across several "kinds" of XML files.
For example:

<?xml version="1.0" encoding="windows-1251"?>
<ROOT>
<REC VALUE="ONE" CODENAME="T21" DATE="01.05.2019" NEWDATE="31.12.2021"/>
<REC VALUE="TWO" CODENAME="D37" DATE="08.01.2014" NEWDATE="31.12.2021"/>
</ROOT>


And this one:
<?xml version="1.0" encoding="Windows-1251"?>

<NEW_LIST>

  <ZAGOLOVOK>
    <VERSION>1.0</VERSION>
    <DATE>09-01-2020</DATE>
  </ZAGOLOVOK>
  
  <SUMMARY>
    <NUMBER>34550677</NUMBER>
    <YEAR>2015</YEAR>
  </SUMMARY>

<RECORD>
    <NUMBER_RECORD>1</NUMBER_RECORD>
    <SUBNUMBER>0</SUBNUMBER>
    <CLIENT>
      <ID_CLIENT>904-374-395-424</ID_CLIENT>
      <POL>1</POL>
    </CLIENT>
    <CASE>
      <CASE_NUMBER>18534026</CASE_NUMBER>
      <OK>1</OK>
      <C_TYPE>1</C_TYPE>
      <C_POD>22</C_POD>
      <IDNUM>566743434</IDNUM>    
      <TURN>
        <IDTURN>5680</IDTURN>
        <TVAL>6676766669</TVAL>
        <DONE>1</DONE>        
      </TURN>
    </CASE>
  </RECORD>
  
</NEW_LIST>


Previously, I tried to work with given documents using System.Xml (C#), but I got a message about the wrong document structure. Therefore, it was necessary to parse the file as a text file.

Question - What are xml files and how to check them for validity?
The fact that there are standards and rules for writing a document, I know and even read them somewhere (for a long time).
But when I googled "xml validator", I saw that there are several of them now.
For files of state companies, one, for other companies, others.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hanneman, 2020-07-21
@Hanneman

Both of the examples you've given are valid and not something separate and isolated - both have both root elements and tags (in the first - empty with attributes, in the second - initial without attributes and end).
XML has its own standard: in an element, attributes can only be used in the start tag and the empty element tag. In your examples: in the first - empty tags have attributes, in the second there are no attributes - simply because they are not needed. Just read about XML - attributes there have the same meaning as in HTML: not every tag in HTML must have an attribute - they put it where it is needed by the task.
Those. if extrapolated to HTML, then your question looks like this and looks strange:
What are HTML files?
Here is example 1

<p>
  <img src="example.gif" alt="example" style="width:42px;height:42px;" />
</p>

And here is example 2
<table>
  <tr>
    <th>Имя</th>
    <th>Фамилия</th>
    <th>Возраст</th>
  </tr>
</table>

What is the difference?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question