find un-closed tags in XML files

Hi All,

I am trying to validate XMLs from a folder:

Input Directory having multiple XML files:

File1.xml

<Root>
  <Parent>
     <Child Name="One">
        <Foo>...</Foo>
        <Bar>...</Bar>
        <Baz>...</Baz>
     </Child>
     <Child Name="Two">
        <Foo>...</Foo>
        <Bar>...</Bar>

File2.xml

<Root>
  <Parent>
     <Child Name="One">
        <Foo>...</Foo>
        <Bar>...</Bar>
        <Baz>...</Baz>
     </Child>
     <Child Name="Two">
        <Foo>...
        <Bar>...</Bar>
     </Child>
  </Parent>
</Root>

File3.xml

<Root>
  <Parent>
     <Child Name="One">
        <Foo>...</Foo>
        <Bar>...</Bar>
        <Baz>...</Baz>
     </Child>
     <Child Name="Two">
        <Foo>...</Foo>
        <Bar>...</Bar>
     </Child>
  </Parent>
</Root>

My output should be:
File1.xml & File2.xml doesn't having proper closed tags these files have to store in Folder1

File3.xml having proper closed tags so these file has to be stored in Folder2

I don't know how to start with.. could you please help in this.

Thanks in advance

Regards,
Ulf

Before we start dreaming up awk or sed solutions for your request, you should try to find xml specific tools doing exactly this for you - and I'm sure there will be abundant thereof, on these forums, or found by google.

Actually what you are trying to do is check that your XML is "well-formed". Well-formed and valid are two completely different concepts in XML. A document, i.e. file containing your XML, can be well-formed but not valid. However if it is a valid document, by definition it must be well-formed.

Do an Internet search for "check XML well-formedness" and you should find some utilities that will do what you want. Such tools include xmlproc and xmlproc_val.

Thanks all I will check for it.