Ошибка xml mismatched end tag

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/tab1"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ScrollView
            android:id="@+id/scrollView1"
            android:layout_width="wrap_content"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:text="About the course"
                    android:textColor="#0000ff"
                    android:textSize="20dp" />

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:text="This course equips you the skills to handle and manage the technology that is so vital in the field of media and communication, namely digital communication, wireless devices, broadband, media design and other emerging media and telecommunication technologies."
                    android:textColor="#0000ff"
                    android:textSize="14dp" />
                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="214dp"
                    android:layout_height="171dp"
                    android:layout_marginTop="10dp"
                    android:adjustViewBounds="true"
                    android:padding="10dp"
                    android:scaleType="fitStart"
                    android:src="@drawable/cinema4d"
                    android:layout_gravity="center" />
                <TextView
                    android:id="@+id/textView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:textColor="#0000ff"
                    android:text="What you learn:"
                    android:textSize="14dp" />
                <TextView
                    android:id="@+id/textView4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:textColor="#0000ff"
                    android:textSize="14dp" 
                    android:text="Enrol in subjects on the fundamentals of media and communication technology and refine your specialisation by choosing elective subjects in areas such as multimedia networking and applications, wireless and mobile communications, and digital broadcasting with emphasis on a 'hands-on. minds-on' approach."/>
                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="214dp"
                    android:layout_height="171dp"
                    android:layout_marginTop="10dp"
                    android:adjustViewBounds="true"
                    android:padding="10dp"
                    android:scaleType="fitStart"
                    android:src="@drawable/fdmp"
                    android:layout_gravity="center" />                
        </ScrollView>
    </LinearLayout>    
</LinearLayout>

my code was fine and i tested out a few times and it work until the error parsing xml mismatched appear and i can’t seem to find the error.
After i add the imageview the following error appears when i try to build :
Multiple annotations found at this line:
— error: Error parsing XML: mismatched tag
— The element type «LinearLayout» must be terminated by the matching end-tag «».
Does someone know whats wrong with my code?
thanks

Dipak Keshariya's user avatar

asked Aug 20, 2012 at 18:38

realityss's user avatar

0

The error message is quite accurate:

Multiple annotations found at this line: — error: Error parsing XML:
mismatched tag — The element type «LinearLayout» must be terminated
by the matching end-tag

Your xml opens up two <LinearLayout> tags (one on the first line, one as the first element of the <ScrollView>) but it only closes one.

Adding a </LinearLayout> before </ScrollView> should resolve this.

answered Aug 20, 2012 at 18:49

Anders Lindahl's user avatar

Anders LindahlAnders Lindahl

41.3k8 gold badges88 silver badges93 bronze badges

0

You need a </LinearLayout> tag before your </ScrollView>

answered Aug 20, 2012 at 19:21

BlackHatSamurai's user avatar

BlackHatSamuraiBlackHatSamurai

23.2k21 gold badges95 silver badges156 bronze badges

I’m trying to fix an XML file with thousands of lines that have the error:

Opening and ending tag mismatch error

I’m using right now simpleXML to parse this file, so before parse with this librarie I need to fix the XML file:

Right now I’m trying with this solution but it’s not enough:

libxml_use_internal_errors(true);
$xml = @simplexml_load_file($temp_name);
     $errors = libxml_get_errors();
     foreach ($errors as $error) {
         if (strpos($error->message, 'Opening and ending tag mismatch')!==false) {
             $tag   = trim(preg_replace('/Opening and ending tag mismatch: (.*) line.*/', '$1', $error->message));
             $lines = file($temp_name, FILE_IGNORE_NEW_LINES);
             $line  = $error->line+1;
             echo $line;
             echo "<br>";
             $lines[$line] = '</'.$tag.'>'.$lines[$line];
             file_put_contents($temp_name, implode("n", $lines));
         }
     }

Any idea?

Mogsdad's user avatar

Mogsdad

44.5k21 gold badges150 silver badges272 bronze badges

asked Aug 25, 2014 at 20:19

rguzmanrosales's user avatar

2

First, if you’ve got corrupt data then fixing the program that generated it is usually more important than repairing the data.

If the only errors in the file are mismatched end tags, then presumably the repair strategy is to ignore what’s in the end tag entirely, given that the name appearing in an XML end tag is redundant. You might find that an existing tool such as TagSoup or validator.nu handles this the way you want; or you might find that such a tool outputs XML which can be transformed into the form you want. That’s a better prospect than writing your own parser for this non-XML grammar.

answered Aug 26, 2014 at 9:56

Michael Kay's user avatar

Michael KayMichael Kay

155k11 gold badges91 silver badges163 bronze badges

I think this is simple solution.

Please check on your ending tag.

For example this should be correct.

$xml.="</childelement>";

Instead of

$xml.="<childelement/>";

answered Mar 22, 2016 at 1:28

Faris Rayhan's user avatar

Faris RayhanFaris Rayhan

4,4401 gold badge22 silver badges19 bronze badges

Добрый день.

Я не программист.

Есть сайт, на сайте работает отображение погоды.
Недавно это работать перестало.

В результате разбора выяснил, что погода берется из страницы xml.meteoservice.ru/export/gismeteo/point/146.xml
Эта страница загружается и затем парсится
При парсинге идет ошибка
Error while parsing data for «xml.meteoservice.ru/export/gismeteo/point/146.xml»
DOMDocument::loadXML(): Opening and ending tag mismatch: hr line 5 and body in Entity, line: 6

Вот кусок кода , где идет прерывание
$url = vsprintf(‘http://xml.meteoservice.ru/export/gismeteo/point/%s.xml’, array($idCity));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);

try {
$dom = new DOMDocument();
$dom->strictErrorChecking = false;
$dom->loadXML($data);
$xml = simplexml_import_dom($dom);
} catch (Exception $e) {
print «Error while parsing data for «{$url}»rn»;
print $e->getMessage() . «rn»;
return false;
}

В результате гугления на тему DOMDocument::loadXML(): Opening and ending tag mismatch выяснилось , что это происходит если xml не валидный

Если содержимое страницы https://www.meteoservice.ru/export/gismeteo/point/… скопировать в xml валидатор и проверить — то ошибок нет.

Куда копать дальше — непонятно. Прошу подсказать, что не так и почему возникает ошибка.

Skip to navigation
Skip to main content

Red Hat Customer Portal

Infrastructure and Management

  • Red Hat Enterprise Linux

  • Red Hat Satellite

  • Red Hat Subscription Management

  • Red Hat Insights

  • Red Hat Ansible Automation Platform

Cloud Computing

  • Red Hat OpenShift

  • Red Hat OpenStack Platform

  • Red Hat OpenShift Container Platform

  • Red Hat OpenShift Data Science

  • Red Hat OpenShift Dedicated

  • Red Hat Advanced Cluster Security for Kubernetes

  • Red Hat Advanced Cluster Management for Kubernetes

  • Red Hat Quay

  • OpenShift Dev Spaces

  • Red Hat OpenShift Service on AWS

Storage

  • Red Hat Gluster Storage

  • Red Hat Hyperconverged Infrastructure

  • Red Hat Ceph Storage

  • Red Hat OpenShift Data Foundation

Runtimes

  • Red Hat Runtimes

  • Red Hat JBoss Enterprise Application Platform

  • Red Hat Data Grid

  • Red Hat JBoss Web Server

  • Red Hat Single Sign On

  • Red Hat support for Spring Boot

  • Red Hat build of Node.js

  • Red Hat build of Quarkus

Integration and Automation

All Products

Symptom

The following error occurs:

error: (name_of_guest.xml):61: Opening and ending tag mismatch: clock line 16 and domain
</domain>
---------^
Investigation

The error message above contains three clues to identify the offending tag:

The message following the last colon, clock line 16 and domain, reveals that <clock> contains a mismatched tag on line 16 of the document. The last hint is the pointer in the context part of the message, which identifies the second offending tag.

Unpaired tags must be closed with />. The following snippet does not follow this rule and has produced the error message shown above:

<domain type='kvm'>
  ...
    <clock offset='utc'>

This error is caused by mismatched XML tags in the file. Every XML tag must have a matching start and end tag.

Other examples of mismatched XML tags

The following examples produce similar error messages and show variations of mismatched XML tags.

This snippet contains an unended pair tag for <features>:

<domain type='kvm'>
 ...
 <features>
   <acpi/>
   <pae/>
 ...
 </domain>

This snippet contains an end tag (</name>) without a corresponding start tag:

<domain type='kvm'>
  </name>
  ...
</domain>
Solution

Ensure all XML tags start and end correctly.

   Renat11111

28.05.13 — 09:57

Пару дней назад код стал давать ошибку, на разных компах.

   ТекДата = Формат(тДатаФайла,»ДФ=dd.MM.yyyy»);

   ИмяФайла = «http://www.cbar.az/currencies/»+ТекДата+».xml»;

   ЧтениеXML = Новый ЧтениеXML;

   ЧтениеXML.ОткрытьФайл(ИмяФайла);

Ошибка вылетает вот на этой строке Пока ЧтениеXML.Прочитать()Цикл

Плиз у кого идеи есть подскажите. Кэш чистил, больше ничего в голову не приходит.

   zak555

1 — 28.05.13 — 09:59

забей на афгании, пользуйся рублями

   Renat11111

2 — 28.05.13 — 09:59

(1) хотелось бы.

   Renat11111

3 — 28.05.13 — 10:00

файлы xml на сайте есть, видимо что то поменялось в структуре файла, что вызывает ошибку. вот пример http://www.cbar.az/currencies/28.05.2013.xml

   zak555

4 — 28.05.13 — 10:01

формат даты какой ?

   zak555

5 — 28.05.13 — 10:01

(3) он перестал быть xml ?

   zak555

6 — 28.05.13 — 10:01

=)

   Renat11111

7 — 28.05.13 — 10:03

   zak555

8 — 28.05.13 — 10:04

ты его скачай, а потом парси

   Ненавижу 1С

9 — 28.05.13 — 10:04

   Renat11111

10 — 28.05.13 — 10:05

(8) три года эта обработка работала без проблем.

   Renat11111

11 — 28.05.13 — 10:05

не могу понять что поменялось

   zak555

12 — 28.05.13 — 10:06

(10) плохая обработка, которая не качала

(11) афганцы настроили сервер ?

   Renat11111

13 — 28.05.13 — 10:10

(12) нех… делать?. Папа про войну в детстве рассказывал? что ты к афганцам прицепился?

   zak555

14 — 28.05.13 — 10:11

(13) так они наркобарыги

а ты пытаешься кому-то накробарыжную валюту учёта настроить, а люди гибнут

   Renat11111

15 — 28.05.13 — 10:12

(14) ясно задрот, которому нех делать

   zak555

16 — 28.05.13 — 10:17

он у тебя в штанах

   AaNnDdRrEeYy

17 — 28.05.13 — 10:54

(14) это Азербайджан а не Авганистан- они вообще в разных местах.

   zak555

18 — 28.05.13 — 10:57

(17) точно =)

кстати, в азербайджане коноплю выращивают прямо во дворах

так что они все из одной степни

   AaNnDdRrEeYy

19 — 28.05.13 — 10:58

вот так попробуй

ТекДата = Формат(тДатаФайла,»ДФ=dd.MM.yyyy»);

   ИмяФайла = «http://www.cbar.az/currencies/»+ТекДата+».xml»;

КопироватьФайл(ИмяФайла,КаталогВременныхФайлов()+temp.xml)  

   ЧтениеXML = Новый ЧтениеXML;

   ЧтениеXML.ОткрытьФайл(КаталогВременныхФайлов()+temp.xml);

   zak555

20 — 28.05.13 — 11:00

(19) HTTPСоединением его не надо ?

   Renat11111

21 — 28.05.13 — 11:28

(19) щас возможности нет проверить. Уже на вечер.

(20) вспомнил тупого американского президента бывшего. Он тоже также все страны путал. Правда он врядли задрот

   zak555

22 — 28.05.13 — 16:30

тебя слово задрот преследует видимо по жизни

плохо тебе видать

   Лефмихалыч

23 — 28.05.13 — 16:32

(0) текст ошибки предлагаешь угадать?

   Renat11111

24 — 29.05.13 — 11:42

(19)

Ничего не изменилось к сожалению.

сделал так

КопироватьФайл(ИмяФайла,КаталогВременныхФайлов()+»/temp.xml»);  

   ЧтениеXML = Новый ЧтениеXML;

   ЧтениеXML.ОткрытьФайл(КаталогВременныхФайлов()+»/temp.xml»);

(23) Замечание существенно

{Обработка.ЗагрузкаКурсовВалют.Форма.Форма(36)}: Ошибка при вызове метода контекста (Прочитать)

           Пока ЧтениеXML.Прочитать()Цикл

по причине:

по причине:

Ошибка разбора XML:  — [6,8]

Фатальная ошибка:

Opening and ending tag mismatch: hr line 0 and body

SystemId: file://C:/Users/HP/AppData/Local/Temp/temp.xml

   Renat11111

25 — 29.05.13 — 11:46

До вызова метода Проочитать() в отладчике свойство ЧтениеXML ТипУзла = Ничего. Что то не так с самим файлом.

   Renat11111

26 — 29.05.13 — 11:46

в самом файле первые 2 строки пустые может с этим ошибка связана?

   Ёпрст

27 — 29.05.13 — 12:04

(26)ну удали — узнаешь, тот, что по ссылке в (7) рабочий, ошибков в нём нет

   Renat11111

28 — 29.05.13 — 12:11

(27) тут новые подробности

http://www.cbar.az/currencies/29.05.2013.xml вот этот файл IE открывается без проблем.

а вот этот дает ошибку C:UsersHPAppDataLocalTemptemp.xml

Не удается отобразить страницу XML

Не удается просмотреть ввод XML с использованием списка стилей XSL. Исправьте ошибку и затем нажмите кнопку «Обновить» или повторите попытку позднее.

———————————————————————————

Тег конца «body» не соответствует тегу начала «hr». Ошибка при обработке ресурса »file:///C:/Users/HP/AppData/Local/Temp/t…

</body>

—^

   Ёпрст

29 — 29.05.13 — 12:13

(28) вообще-то боди и прочая шляпа, к этому файлу вообще ни коим боком, ты его в блокноте открой и посмотри, че там..

   Renat11111

30 — 29.05.13 — 12:13

(27) получается все же что то в файле (7) не так

   Ёпрст

31 — 29.05.13 — 12:14

сдается мне, что ты не тот файлик открыть пытаешься.

   Renat11111

32 — 29.05.13 — 12:15

(31) самый тот

ИмяФайла = «http://www.cbar.az/currencies/»+ТекДата+».xml»;

   КопироватьФайл(ИмяФайла,КаталогВременныхФайлов()+»temp.xml»);  

   ЧтениеXML = Новый ЧтениеXML;

   ЧтениеXML.ОткрытьФайл(КаталогВременныхФайлов()+»temp.xml»);

   Renat11111

33 — 29.05.13 — 12:16

(31) все таки непонятно почему при копировании файла он нормально не сохраняется в темпорари.

   Ёпрст

34 — 29.05.13 — 12:19

(33) а ты выложи тот, что в тепах у тебя на поглядеть

   Renat11111

35 — 29.05.13 — 12:20

в нем только это:

Не удается отобразить страницу XML

Не удается просмотреть ввод XML с использованием списка стилей XSL. Исправьте ошибку и затем нажмите кнопку «Обновить» или повторите попытку позднее.

———————————————————————————

Тег конца «body» не соответствует тегу начала «hr». Ошибка при обработке ресурса »file:///C:/Users/HP/AppData/Local/Temp/t…

</body>

—^

   Renat11111

36 — 29.05.13 — 12:21

если в мозиле открыть, то ошибка уже с 1с совпадает

This page contains the following errors:

error on line 6 at column 8: Opening and ending tag mismatch: hr line 0 and body

Below is a rendering of the page up to the first error.

301 Moved Permanently 301 Moved Permanently nginx/1.4.1

   Renat11111

37 — 29.05.13 — 12:23

если открыть блокнотом как ты говорил то содержимое:

<html>

<head><title>301 Moved Permanently</title></head>

<body bgcolor=»white»>

<center><h1>301 Moved Permanently</h1></center>

<hr><center>nginx/1.4.1</center>

</body>

</html>

   Ёпрст

38 — 29.05.13 — 12:27

Ну вот и ответ.. скачиваешь просто заголовок, а не сам xml

   Ёпрст

39 — 29.05.13 — 12:27

мот надо запрос какой писать, для получения файла..

   Ёпрст

40 — 29.05.13 — 12:34

всё, я нашел в чем у тебя ошибка

   Ёпрст

41 — 29.05.13 — 12:35

Исправь на

//  ИмяФайла = «http://www.cbar.az/currencies/»+ТекДата+».xml»;

 ИмяФайла = «http://cbar.az/currencies/»+ТекДата+».xml»;

и наслаждайся

   Renat11111

42 — 29.05.13 — 12:39

(41) что на что исправить я не понял честно говоря.

   Renat11111

43 — 29.05.13 — 12:40

аааа

   Renat11111

44 — 29.05.13 — 12:40

щас попробую

   Ёпрст

45 — 29.05.13 — 12:40

(41) твой вариант закомменчен, убери www из строки.

   Renat11111

46 — 29.05.13 — 12:41

(45) понял уже щас проверяю.

   Serginio1

47 — 29.05.13 — 12:42

А почему не воспользоваться

httpServer=»www.cbar.az»;

aфдрес=»currencies/»+ТекДата+».xml»;

Хттп=Новый HTTPСоединение(httpServer);

Хттп.Получить(Адрес,ИмяФайла);

   Renat11111

48 — 29.05.13 — 12:43

(45) ты даже не представляешь. как я тебе благодарен ))) спасибо. ВСЕ ЖЕ интересно почему раньше 3 года работало щас перестало.

   Ёпрст

49 — 29.05.13 — 12:43

(47) можно и так..

  

Renat11111

50 — 29.05.13 — 12:50

Ну все пожалуй тема закрыта. Еще раз всем спасибо.

Понравилась статья? Поделить с друзьями:
  • Ошибка xls0501 свойство content установлено больше одного раза
  • Ошибка xlive для colin mcrae dirt
  • Ошибка xlive dll при запуске gta 4
  • Ошибка xlive dll не был найден gta 4
  • Ошибка xlive dll warhammer 40000