XML

From wiki
Revision as of 21:21, 7 September 2018 by Hdridder (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Generic remarks about XML.

Comments start with <!-- and end with -->. Comments cannot be nested.

Perl Regular Expressions to check if we enter or leave a comment block

 if ( ( $line =~ /-->/ ) && ( $incomment == 1 )) {
  $incomment = 0;
  $line =~ s/(<!--)?.*$&//;
 }
 if ( $incomment == 0 ) {
  if ( $line =~ /<!--/ ) {
   $incomment = 1;
   $line =~ s/$&.*?(-->)//;
   if ( $1 ) {
    $incomment = 0;
   }
  }

Python module and code examples Python:XML.

xmllint --noout <xmlfile>
Test if <xmlfile> has valid xml and report errors. Without --noout the tree will be printed too.