Tag Archives: xml

Vs2019 + QT parses the XML file and reports an error at doc.setcontent (& file)

Vs2019 + QT parses the XML file and reports an error at doc.setcontent

Made a very low-level mistake. Record the process.

A QT project was established long ago. Now to add a function of parsing XML files using the qdom class, there is always an error in the sentence doc.setcontent (& amp; file) , and there is no error message. The relevant C + + codes are as follows:

QString error;
int line, column;
if (doc.setContent(&file, &error, &line, &column)) {
    qDebug() << doc.toString(4);
}
else {
    qDebug() << "Error:" << error << "in line " << line << "column" << column;
}
file.close();

When doc.setcontent (& amp; file, & amp; error, & amp; line, & amp; column) , critical error detected c00000374 is displayed

The first reaction is that the XML file is incorrectly written. For example, there is no space in the space, Chinese punctuation is entered, or the two sides of the tag are inconsistent
after repeatedly confirming that the XML file is correct, the stackoverflow search said that the relative path cannot be used, but the absolute path must be used… Another attempt of the absolute path is useless.

Create a new project and run it with the same code without error. Through careful comparison, it is found that in the new project, I added the XML class library

but not in the original project!

So far, add $(qtdir) \ include \ qtxml in the C/C + + include directory, add qt5xmld.lib [debug mode] and qt5xml. Lib [release mode] in the linker, and the operation is successful!

Finally, I found that if the XML file is written incorrectly, the above program can locate the error location. Direct reporting of fatal error/critical error or unresolved external symbols like this__ declspec(dllimport) public: __ Cdecl , the probability is that the Lib file link is wrong rather than the code problem. You need to check whether the environment is configured correctly.

A simple question has been wordy for a long time… Mainly to warn yourself that you must think more and think more about ways to expose the problem when you encounter a problem that has no solution on the Internet!

Solutions to error reporting after adding comments to XML files

It took a long time to find the most useful way to feel
set the <?xml version=”1.0″ encoding=”UTF-8″ ?>
change to <?xml version=”1.0″ encoding=”UTF8″ ?>
that is to say, remove –
during the process, I searched a lot of methods on the Internet. If the above methods don’t work, I can try the following two methods:
1. Add configuration in pom.xml file

<properties>
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

2. Change the idea configuration

note: it is only during the process of finding that the XML annotation format is

<!-- Contents --> Right
<! --content --> wrong
To be separated by two spaces, but I do not think it has much impact, after changing the format still does not support comments

Error in web.xml file: error while downloading

Complete error message: error while downloading‘ http://www.w3.org/2001/xml.xsd ’To C:
\ users \ jarvis5. Lemminx \ cache \ http \ www.w3. ORG \ 2001 \ xml.xsd. It is speculated that there should be an error in the file download path. According to the error information, find the folder under the relevant path. It is found that there are two folders: http and HTTPS, As shown in the figure:
click the two folders and find the file content prompted in the error message (www.w3. Org/2001/XML. XSD) in the HTTPS file, so change the HTTP in the XML file to HTTPS and the error message disappears
before modification:

After modification:

or add & lt; xml-body> tag, the error message disappears:

(the content is for reference only, please point out if there is an error!)

WordPress website map sitemap.xml error repair

WordPress website map sitemap.xml error repair

Error overview

In building a website using WordPress, use the XML Sitemaps plug-in to create a sitemap.xml site map, but after creation, open sitemap.xml and report the following error

Solution

1. Find the wp-blog-header.php file in the root directory of the website and open it. Modify it as follows

<?php
if ( ! isset( $wp_did_header ) ) {
	$wp_did_header = true;ob_start();
	// Load the WordPress library.
	require_once __DIR__ . '/wp-load.php';
	// Set up the WordPress query.
	wp(); ob_end_clean();
	// Load the theme template.
	require_once ABSPATH . WPINC . '/template-loader.php';
}

2. Refresh sitemap.xml to find that it can be used

maven_ Unable to create servlet file under Java Web project

Add the following code in pom.xml:

<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>javax.servlet-api</artifactId>
   <version>4.0.1</version>
   <scope>provided</scope>
</dependency>
 
<!-- https://mvnrepository.com/artifact/jstl/jstl -->
<dependency>
   <groupId>jstl</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>
</dependency>

After Android studio creates a new bottomnavigationactivity, there is a blank solution in the upper area of fragment

Problem description

For example, the screenshot is as follows, which is often empty above and incomplete below (recyclerview list) (blocked by the navigation bar at the bottom)

Problem solving ideas

After switching to another fragment, it is found that it is also lower than the whole, so it should be the whole setting problem, so the problem is located to activity_ Main.xml or mobile_ In navigation. XML, which is used to specify the newly created fragment, it turns out to be an activity_ Main.xml specifies mobile_ There’s a problem with navigation’s fragment.

Problem solving

At activity_ In main.xml

    deleting the paddingtop attribute of the outermost constraintlayout will @ + ID/NAV_ host_ Layout of fragment_ Height is set to 0dp

    result


Solution to the problem that some special characters in finereport cannot be displayed or displayed as question mark

M ² In the case of no processing, finereport will ² What is it
it’s not that finereport doesn’t support it, it’s because of the problem of character set conversion
solution:
in WEB-INF/resources/config.xml

<Write serverCharacterEncoding="GBK"/>

Change to:

<Write serverCharacterEncoding="UTF-8"/>

After restarting the service, you can see the ² It’s over

Org.springframework.beans.factory.xml.xmlbeandefinitionstoreexception: the wildcard matching is comprehensive, but the declaration of element XX: XX XX cannot be found

When configuring spring’s XML file, you want to start component scanning. As a result, the following error occurred during the operation:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd">
    <context:component-scan base-package="com.zxb"></context:component-scan>
</beans>

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from class path resource [bean2.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 52; CVC complex type. 2.4. C: wildcard matching is comprehensive, but the element cannot be found‘ context:component-scan ’A statement from the government.

After searching for a long time, it turned out that in the XML file, you need to specify the specific location of the schema file to be followed through the schemalocation . I forgot to configure it, just add it.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context" 
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context.xsd">
    <context:component-scan base-package="com.zxb"></context:component-scan>
</beans>

It’s not detailed enough~

Python IndexError: too many indices for array: array is 1-dimensional, but 2 were i..

This is the reason why there are empty tags in the XML files in the dataset.
first of all, what are empty Tags:
& <zhoz>& </ zhoz> this form, that is, there is no value in it
normal should be & < zhoz> 56 this form

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
 
# Move the xml with empty tags and move the corresponding images synchronously
import os
import xml.etree.ElementTree as ET
import shutil
 
origin_ann_dir = '/home/data_1/project/big-obj/RefineDet.PyTorch/data/VOCdevkit/VOC2007/Annotations/'# Set the original tag path to Annos
new_ann_dir = '/home/data_1/project/big-obj/RefineDet.PyTorch/data/VOCdevkit/VOC2007/xml-save/'# Set the new tag path Annotations
origin_pic_dir = '/home/data_1/project/big-obj/RefineDet.PyTorch/data/VOCdevkit/VOC2007/JPEGImages/'
new_pic_dir = '/home/data_1/project/big-obj/RefineDet.PyTorch/data/VOCdevkit/VOC2007/pic-save/'
k=0
p=0
q=0
for dirpaths, dirnames, filenames in os.walk(origin_ann_dir):  
  for filename in filenames:
    print("process...")
    k=k+1
    print(k)
    if os.path.isfile(r'%s%s' %(origin_ann_dir, filename)):   # get the absolute path to the original xml file, isfile() detects if it is a file isdir detects if it is a directory
      origin_ann_path = os.path.join(r'%s%s' %(origin_ann_dir, filename)) # If yes, get absolute path (repeat code)
      new_ann_path = os.path.join(r'%s%s' %(new_ann_dir, filename))
      tree = ET.parse(origin_ann_path)  
      root = tree.getroot()   
      if len(root.findall('object')):
        p=p+1
      else:
        print(filename)
        old_xml = origin_ann_dir + filename
        new_xml = new_ann_dir + filename
        old_pic = origin_pic_dir + filename.replace("xml","jpg")
        new_pic = new_pic_dir + filename.replace("xml","jpg")
        q=q+1
        shutil.move(old_pic, new_pic)
        shutil.move(old_xml, new_xml)
print("ok, ",p)
print("empty, ",q)

Found the XML file that generated the empty tag. The contents are as follows:

<annotation>
	<folder>obj1344</folder>
	<filename>obj1344_frame0000172.jpg</filename>
	<path>D:\Research\valid\obj1344\obj1344_frame0000172.jpg</path>
	<source>
		<database>Unknown</database>
	</source>
	<size>
		<width>480</width>
		<height>270</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
</annotation>

After the XML file is found, the image needs to be annotated again. After opening labelimg to annotate the data, the content of the XML file is as follows:

<annotation>
	<folder>JPEGImages</folder>
	<filename>obj1344_frame0000172.jpg</filename>
	<path>D:\new\SSD-master\datasets\VOC2007\JPEGImages\obj1344_frame0000172.jpg</path>
	<source>
		<database>Unknown</database>
	</source>
	<size>
		<width>480</width>
		<height>270</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
	<object>
		<name>plastic</name>
		<pose>Unspecified</pose>
		<truncated>1</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>181</xmin>
			<ymin>144</ymin>
			<xmax>355</xmax>
			<ymax>270</ymax>
		</bndbox>
	</object>
	<object>
		<name>timestamp</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>10</xmin>
			<ymin>5</ymin>
			<xmax>471</xmax>
			<ymax>43</ymax>
		</bndbox>
	</object>
	<object>
		<name>timestamp</name>
		<pose>Unspecified</pose>
		<truncated>1</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>14</xmin>
			<ymin>216</ymin>
			<xmax>480</xmax>
			<ymax>270</ymax>
		</bndbox>
	</object>
</annotation>

Modify and replace the original XML file to run.