0

when I run my python code I get the following error: Valid XML should start with '<?xml ...?>'

for i in range(1, 18):
    hand_cascade = cv2.CascadeClassifier(f'./class/{i}.xml')
    hand_cascades.append(hand_cascade)

My XML file :

<?xml version="1.0" encoding="UTF-8"?>

<root>
  <worksheet name="Sheet1">
    <Row index="1">
      <filename>20230305_201635.jpg</filename>
      <file_size>189436</file_size>
      <file_attributes>{}</file_attributes>
      <region_count>1</region_count>
      <region_id>0</region_id>
      <region_shape_attributes>
        {"name":"polyline","all_points_x":[507,684,885,988,1039,1147,1214,1212,1196,1146,1135,1137,1106,1073,1051,1019,1009,978,968,935,906,781,728,661,575,476,446,447,419,387],"all_points_y":[3,97,201,224,233,278,321,347,359,352,347,364,379,368,347,331,346,344,343,350,350,318,306,317,298,243,198,185,163,146]}</region_shape_attributes>
      <region_attributes>{}</region_attributes>
    </Row>
   
  </worksheet>
</root>

What's going on and how can I fix it?

Yaniv
  • 1
  • Make sure there's no white space before the declaration. Just a single space before ` – LMC Mar 07 '23 at 23:26
  • Different error message but follow the solutions listed here as it's likely the same problem: [Error: The processing instruction target matching "xXmMlL" is not allowed](https://stackoverflow.com/q/19889132/290085). Note also that an XML declaration is optional for version 1.0 and UTF-8 encoding (which your XML declaration specifies). – kjhughes Mar 07 '23 at 23:48
  • I saw one report suggesting that this particular parser might be objecting to a file that starts with a BOM sequence - which should be accepted, but this isn't always the case especially for older parsers. – Michael Kay Mar 08 '23 at 00:27

0 Answers0