Ошибка xml parsing error not well formed

I am working on an application, with following XML. but whenI try to clean/build my project the following error occurs:

«error: Error parsing XML: not well-formed (invalid token)»

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello";
/>
</LinearLayout>

What does it possibly mean?

Sree's user avatar

Sree

3,1262 gold badges31 silver badges39 bronze badges

asked Aug 17, 2011 at 8:19

Usama Sarwar's user avatar

Usama SarwarUsama Sarwar

8,8727 gold badges53 silver badges79 bronze badges

1

I had this problem, and when I had android:text="< Go back" it had the correct syntax highlighting, but then I realized it’s the < symbol that is messing everything up.

answered Jan 23, 2016 at 2:18

Rock Lee's user avatar

3

It means there is a compilation error in your XML file, something that shouldn’t be there: a spelling mistake/a spurious character/an incorrect namespace.

Your issue is you’ve got a semicolon that shouldn’t be there after this line:

  android:text="@string/hello";

answered Aug 17, 2011 at 8:21

Blundell's user avatar

BlundellBlundell

75.5k30 gold badges208 silver badges233 bronze badges

3

I had same problem. you can’t use left < arrow in text property like as android:text="< Go back" in your xml file. Remove any < arrow from you xml code.

Hope It will helps you.

answered Dec 29, 2016 at 6:17

Dalvinder Singh's user avatar

Dalvinder SinghDalvinder Singh

1,0631 gold badge12 silver badges19 bronze badges

1

Verify that you don’t have any spaces or tabs before

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

also refresh and clean your project in eclipse.

I get this error every now and then and the above suggestions fix the issue 99% of the time

answered Aug 17, 2011 at 8:23

Julian Suarez's user avatar

Julian SuarezJulian Suarez

4,5074 gold badges24 silver badges40 bronze badges

To solve this issue, I pasted my layout into https://www.xmlvalidation.com/, which told me exactly what the error was. As was the case with other answers, my XML had < in a string.

answered Apr 20, 2018 at 18:00

Alan Kinnaman's user avatar

Remove the semicolon after hello

answered Nov 30, 2013 at 9:12

Vincent Thacker's user avatar

I had the same problem. In my case, even though I have not understood why, the problem was due to & in one of the elements like the following where a and b are two tokens/words:

<s> . . . a & b . . . </s>

and to resolve the issue I turned my element’s text to the following:

<s> . . . a and b . . . </s>

I thought it might be the case for some of you. Generally, to make your life easier, just go and read the character at the index mentioned in the error message (line:..., col:...) and see what the character is.

answered Nov 18, 2019 at 0:10

Pedram's user avatar

PedramPedram

2,3892 gold badges31 silver badges48 bronze badges

In my case I forgot to end my ConstrainLayout

</android.support.constraint.ConstraintLayout>

After that, everything started working correctly.

answered Dec 6, 2018 at 10:18

Wiktor Kalinowski's user avatar

0

I tried everything on my end and ended up with the following.

I had the first line as:

<?xmlversion="1.0"encoding="utf-8"?>

And I was missing two spaces there, and it should be:

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

Before the version and before the encoding there should be a space.

jkdev's user avatar

jkdev

11.3k15 gold badges54 silver badges77 bronze badges

answered Jul 2, 2019 at 13:30

Michael Fahim's user avatar

Problem is that you are doing something wrong in XML layout file

android:text=" <- Go Back" // this creates error
android:text="Go Back" // correct way

answered Nov 29, 2020 at 7:35

Vijay's user avatar

VijayVijay

1,1558 silver badges22 bronze badges

XML is a widely utilized language for storing, transporting, and organizing data on the web. However, it’s common to encounter errors while parsing XML files. One such error is the ‘Not Well-formed Location’ issue. This comprehensive guide will help you understand and resolve this error, ensuring your XML files are well-structured and easily parsed.

Table of Contents

  1. Understanding XML Parsing Error
  2. Identifying ‘Not Well-formed Location’ Issues
  3. Step-by-Step Guide to Resolving the Error
  4. FAQs
  5. Related Links

Understanding XML Parsing Error

XML parsing errors occur when there’s a problem with the syntax or structure of your XML document. This hinders the XML parser from processing the document correctly. To prevent such errors, it’s essential to follow the XML syntax rules and ensure that your XML files are well-formed.

Identifying ‘Not Well-formed Location’ Issues

‘Not Well-formed Location’ error typically occurs when there’s a syntax issue in your XML document. The error message will point out the line number and column where the problem exists. Some common causes of this error include:

  • Missing or mismatched opening and closing tags
  • Invalid characters within attribute values
  • Incorrectly formatted comments
  • Missing declaration statement

Step-by-Step Guide to Resolving the Error

Follow these steps to resolve the ‘Not Well-formed Location’ error in your XML document:

  1. Review the error message: Carefully read the error message to identify the line and column number where the problem exists.
  2. Locate the issue: Open your XML document in a text editor and navigate to the specified line and column number.
  3. Identify the problem: Analyze the code to figure out the cause of the error. It could be a missing tag, invalid character, or incorrectly formatted comment.
  4. Fix the issue: Correct the syntax issue as per the XML rules.
  5. Validate your XML: Use an XML validator to ensure that your XML document is now well-formed and free of syntax errors.
  6. Test your XML: Re-run your application or parser to verify that the error has been resolved.

FAQs

1. What are XML parsers?

An XML parser is a software library or package that reads XML documents, checks them for well-formedness, and optionally validates them against an XML schema. XML parsers are used by applications to process and extract data from XML files.

2. What does «well-formed» mean in XML?

A well-formed XML document follows the basic syntax rules of XML. It must have a single root element, properly nested tags, matching opening and closing tags, and valid attribute values. A well-formed XML document can be parsed and processed by an XML parser without any errors.

3. What are some common XML syntax rules?

Some common XML syntax rules include:

  • XML documents must have a single root element
  • Opening and closing tags must match and be properly nested
  • Attribute values must be enclosed in single or double quotes
  • XML tags are case-sensitive
  • Comments must be formatted correctly, i.e., <!-- comment -->

4. How do I check if my XML document is well-formed?

To check if your XML document is well-formed, you can use an online XML validator, such as XMLValidation.com. Simply paste your XML code or upload your XML file, and the validator will show any errors or confirm that your document is well-formed.

5. Can I still use an XML document if it’s not well-formed?

No, an XML document that is not well-formed will not be processed correctly by an XML parser. It may cause errors or unexpected behavior in applications that rely on the XML data. It’s essential to ensure your XML document is well-formed before using it in your application or sharing it with others.

  1. XML Validation: Online XML Validator
  2. W3Schools: XML Syntax Rules
  3. MDN Web Docs: XML Parser

RRS feed

  • Remove From My Forums
  • Question

  • I have WinXP Pro SP2.

    I downloaded and installed Visual Web Developer 2005 Express Edition.

    I am going through the Walkthroughs to better understand ASP.NET.

    I got to the Walkthrough: Creating a Web Site with Membership and User Login (ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/dv_vwdcon/html/296c0be6-9ad5-4104-9a1b-a853986fa1a3.htm)

    I performed every step up to Testing Login flawlessly (and every other Walkthrough up to this point). When I press Ctrl+F5 to run the Website I get this error:

    XML Parsing Error: not well-formed
    Location: http://localhost/membership/Default.aspx
    Line Number 1, Column 2:<%@ Page Language=»VB» AutoEventWireup=»false» CodeFile=»Default.aspx.vb» Inherits=»_Default» %>
    -^

     I can’t find any additional information on the problem in the MS Knowledge Bases so I don’t know how to fix it. Suggestions?


Answers

  • What we see that somehow ASPX file is parsed by XML parser.

    ASPX is not an XML and so this error is expected from XML parser.

    I’d recommend you to go to http://forums.asp.net/ to find why this happens.

All replies

  • What we see that somehow ASPX file is parsed by XML parser.

    ASPX is not an XML and so this error is expected from XML parser.

    I’d recommend you to go to http://forums.asp.net/ to find why this happens.

  • .ASPX files can be XML and can be parsed using XML parser. Example:

    <%@ Page Language=»VB» %>
    <script language=»VB» runat=»server»>
        Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            ‘Set response to XML
            Response.ContentType = «text/xml»
            Dim dt As New System.Data.DataTable
            Try
                ‘Set connection string
                Dim connStr As String = «Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password»
                ‘Set Select statement
                Dim sql As String = «SELECT * FROM caddb.dbo.GetVehicles()» ‘Selects from the table valued function GetVehicles
                ‘Create Data Adapter specifying the select statement and connection string
                Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, connStr)
                ‘Fill the DataTable with data
                da.Fill(dt)
            Catch ex As Exception
                ‘If connection failed, write the error instead
                Response.Write(«<Vehicles><error>»)
                Response.Write(ex.ToString)
                Response.Write(«</error></Vehicles>»)
                Exit Sub
            End Try
            ‘Write the XML Version info not required but is sujested
            Response.Write(«<?xml version=’1.0′ encoding=’utf-8′  standalone=’yes’?>»)
            ‘Write the parent node begin
            Response.Write(«<Vehicles>»)
            For Each row As System.Data.DataRow In dt.Rows ‘Cycle through the rows of the data table
                writeRowXML(row) ‘Write the row to XML
            Next
            ‘Write the parent node end
            Response.Write(«</Vehicles>»)
           
        End Sub
        Sub writeRowXML(ByRef row As System.Data.DataRow)
            Response.Write(«<Vehicle>»)
            Response.Write(»    <lat>» + row.Item(«lat»).ToString + «</lat>»)
            Response.Write(»    <lng>» + row.Item(«lng»).ToString + «</lng>»)
            Response.Write(»    <speed>» + row.Item(«speed»).ToString + «</speed>»)
            Response.Write(»    <heading>» + row.Item(«heading»).ToString + «</heading>»)
            Response.Write(»    <time>» + row.Item(«time»).ToString + «</time>»)
            Response.Write(«</Vehicle>»)
        End Sub
    </script>

    The resulting file would be XML. It would look like this:

    <Vehicles>
    <Vehicle>
    <lat>35.3738301</lat>
    <lng>-97.1908954</lng>
    <speed>0</speed>
    <heading>0</heading>
    <time>12/2/2006 1:42:30 AM</time>
    </Vehicle>
    <Vehicle>
    <lat>35.3838409</lat>
    <lng>-97.1908963</lng>
    <speed>45</speed>
    <heading>180</heading>
    <time>12/2/2006 1:42:30 AM</time>
    </Vehicle>
    </Vehicles>
  • hi did you ever find a solution to this problem

  • Hi,

    .ASPX file itself is not an XML. When you run it, it can produce XML as its output (as in your example). What sergey is saying is, that for some reason instead of the result fo the execution of your ASPX file (which would be an XML) the ASPX file itself is being parsed by the parser. And that fails (as expected).

    This is probably caused by a misconfiguration of the webserver serving the ASPX files (must be set to execute those and not serve them as a content file).

    Thanks,

  • I figured of this would be a problem with IIS and went to

    Finally I got it fixed this is what I did.

    Start -> settings -> control panel -> Add Remove Programs
    Selected Add Widows components
    Unchecked Internet Information Server (IIS)
    and clicked on  next to uninstall it

    Once I was uninstalled i followed the same process. This timed checked iis insted of
    uncheck to re install iis

    Start -> settings -> control panel -> Add Remove Programs
    Selected Add Widows components
    Checked Internet Information Server (IIS)
    and clicked on  next

    Again registered .net with iis

    Read More.

    http://muruganad.com/ASP.NET/XML-Parsing-Error-not-well-formed.html

    Thanks!
      Murugan
    www.muruganad.com

    • Edited by

      Tuesday, September 8, 2009 9:52 PM

  • This Doesn’t help I still get the error in vs 2008 of

    XML Parsing Error: syntax error
    Location: file:///C:/Users/Matthew.Matthew-PC/Documents/Visual%20Studio%202008/Projects/Go%204%20Ward/special.aspx
    Line Number 1, Column 1:This is a marker file generated by the precompilation tool, and should not be deleted!
    ^

  • I recently encountered this issue and it was solved very easy for me. I encountered it to due to a VS2008 Web Deployment Project. I marked for it to create a virtual directory however under the virtual directory settings it did not have a version of ASP.NET selected. Changing this in IIS fixed this occurrence for me.

    InetMGR

    Right click virtual directory < Properties

    ASP.NET

    Change drop down as appropriate.

    • Proposed as answer by
      Chris Marisic
      Monday, September 21, 2009 5:34 PM
    • Edited by
      Chris Marisic
      Monday, September 21, 2009 5:35 PM
      spelling

  • This Doesn’t help I still get the error in vs 2008 of

    XML Parsing Error: syntax error
    Location: file:///C:/Users/Matthew.Matthew-PC/Documents/Visual%20Studio%202008/Projects/Go%204%20Ward/special.aspx
    Line Number 1, Column 1:This is a marker file generated by the precompilation tool, and should not be deleted!
    ^

    You are loading an .aspx file from the file system. Load it over HTTP from a web server where ASP.NET is installed then it will work. With Visual Studio you have a development server or you can use IIS.


    MVP XML
    My blog

  • Not sure if you figured out this problem yet but try the following solution.

    Click on Start ->Run and type in the following command if you are using .NET 2.0 framework:
    %Windir%Microsoft.NETFrameworkv2.0.50727aspnet_regiis -i

    Once done the .NET Framework will be reinstalled. Your problem had to do with the fact that you no doubt installed the IIS after installing the .NET Framework. If the .NET Framework is not registered with IIS then it will not parse it properly.

  • Thank you. Reinstalling .NET 2.0 solved the issue.


I am working on an application, with following XML. but whenI try to clean/build my project the following error occurs:

«error: Error parsing XML: not well-formed (invalid token)»

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello";
/>
</LinearLayout>

What does it possibly mean?

Sree's user avatar

Sree

3,1162 gold badges31 silver badges39 bronze badges

asked Aug 17, 2011 at 8:19

Usama Sarwar's user avatar

Usama SarwarUsama Sarwar

8,8207 gold badges52 silver badges79 bronze badges

1

I had this problem, and when I had android:text="< Go back" it had the correct syntax highlighting, but then I realized it’s the < symbol that is messing everything up.

answered Jan 23, 2016 at 2:18

Rock Lee's user avatar

3

It means there is a compilation error in your XML file, something that shouldn’t be there: a spelling mistake/a spurious character/an incorrect namespace.

Your issue is you’ve got a semicolon that shouldn’t be there after this line:

  android:text="@string/hello";

answered Aug 17, 2011 at 8:21

Blundell's user avatar

BlundellBlundell

74.5k30 gold badges208 silver badges232 bronze badges

3

I had same problem. you can’t use left < arrow in text property like as android:text="< Go back" in your xml file. Remove any < arrow from you xml code.

Hope It will helps you.

answered Dec 29, 2016 at 6:17

Dalvinder Singh's user avatar

Dalvinder SinghDalvinder Singh

1,0831 gold badge12 silver badges19 bronze badges

1

Verify that you don’t have any spaces or tabs before

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

also refresh and clean your project in eclipse.

I get this error every now and then and the above suggestions fix the issue 99% of the time

answered Aug 17, 2011 at 8:23

Julian Suarez's user avatar

Julian SuarezJulian Suarez

4,4894 gold badges24 silver badges40 bronze badges

To solve this issue, I pasted my layout into https://www.xmlvalidation.com/, which told me exactly what the error was. As was the case with other answers, my XML had < in a string.

answered Apr 20, 2018 at 18:00

Alan Kinnaman's user avatar

Remove the semicolon after hello

answered Nov 30, 2013 at 9:12

Vincent Thacker's user avatar

I had the same problem. In my case, even though I have not understood why, the problem was due to & in one of the elements like the following where a and b are two tokens/words:

<s> . . . a & b . . . </s>

and to resolve the issue I turned my element’s text to the following:

<s> . . . a and b . . . </s>

I thought it might be the case for some of you. Generally, to make your life easier, just go and read the character at the index mentioned in the error message (line:..., col:...) and see what the character is.

answered Nov 18, 2019 at 0:10

Pedram's user avatar

PedramPedram

2,3362 gold badges29 silver badges45 bronze badges

In my case I forgot to end my ConstrainLayout

</android.support.constraint.ConstraintLayout>

After that, everything started working correctly.

answered Dec 6, 2018 at 10:18

Wiktor Kalinowski's user avatar

0

I tried everything on my end and ended up with the following.

I had the first line as:

<?xmlversion="1.0"encoding="utf-8"?>

And I was missing two spaces there, and it should be:

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

Before the version and before the encoding there should be a space.

jkdev's user avatar

jkdev

11.1k15 gold badges55 silver badges77 bronze badges

answered Jul 2, 2019 at 13:30

Michael Fahim's user avatar

Problem is that you are doing something wrong in XML layout file

android:text=" <- Go Back" // this creates error
android:text="Go Back" // correct way

answered Nov 29, 2020 at 7:35

Vijay's user avatar

VijayVijay

1,0858 silver badges22 bronze badges

  • Remove From My Forums
  • Question

  • I have WinXP Pro SP2.

    I downloaded and installed Visual Web Developer 2005 Express Edition.

    I am going through the Walkthroughs to better understand ASP.NET.

    I got to the Walkthrough: Creating a Web Site with Membership and User Login (ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/dv_vwdcon/html/296c0be6-9ad5-4104-9a1b-a853986fa1a3.htm)

    I performed every step up to Testing Login flawlessly (and every other Walkthrough up to this point). When I press Ctrl+F5 to run the Website I get this error:

    XML Parsing Error: not well-formed
    Location: http://localhost/membership/Default.aspx
    Line Number 1, Column 2:<%@ Page Language=»VB» AutoEventWireup=»false» CodeFile=»Default.aspx.vb» Inherits=»_Default» %>
    -^

     I can’t find any additional information on the problem in the MS Knowledge Bases so I don’t know how to fix it. Suggestions?

Answers

  • What we see that somehow ASPX file is parsed by XML parser.

    ASPX is not an XML and so this error is expected from XML parser.

    I’d recommend you to go to http://forums.asp.net/ to find why this happens.

All replies

  • What we see that somehow ASPX file is parsed by XML parser.

    ASPX is not an XML and so this error is expected from XML parser.

    I’d recommend you to go to http://forums.asp.net/ to find why this happens.

  • .ASPX files can be XML and can be parsed using XML parser. Example:

    <%@ Page Language=»VB» %>
    <script language=»VB» runat=»server»>
        Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            ‘Set response to XML
            Response.ContentType = «text/xml»
            Dim dt As New System.Data.DataTable
            Try
                ‘Set connection string
                Dim connStr As String = «Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password»
                ‘Set Select statement
                Dim sql As String = «SELECT * FROM caddb.dbo.GetVehicles()» ‘Selects from the table valued function GetVehicles
                ‘Create Data Adapter specifying the select statement and connection string
                Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, connStr)
                ‘Fill the DataTable with data
                da.Fill(dt)
            Catch ex As Exception
                ‘If connection failed, write the error instead
                Response.Write(«<Vehicles><error>»)
                Response.Write(ex.ToString)
                Response.Write(«</error></Vehicles>»)
                Exit Sub
            End Try
            ‘Write the XML Version info not required but is sujested
            Response.Write(«<?xml version=’1.0′ encoding=’utf-8′  standalone=’yes’?>»)
            ‘Write the parent node begin
            Response.Write(«<Vehicles>»)
            For Each row As System.Data.DataRow In dt.Rows ‘Cycle through the rows of the data table
                writeRowXML(row) ‘Write the row to XML
            Next
            ‘Write the parent node end
            Response.Write(«</Vehicles>»)
           
        End Sub
        Sub writeRowXML(ByRef row As System.Data.DataRow)
            Response.Write(«<Vehicle>»)
            Response.Write(»    <lat>» + row.Item(«lat»).ToString + «</lat>»)
            Response.Write(»    <lng>» + row.Item(«lng»).ToString + «</lng>»)
            Response.Write(»    <speed>» + row.Item(«speed»).ToString + «</speed>»)
            Response.Write(»    <heading>» + row.Item(«heading»).ToString + «</heading>»)
            Response.Write(»    <time>» + row.Item(«time»).ToString + «</time>»)
            Response.Write(«</Vehicle>»)
        End Sub
    </script>

    The resulting file would be XML. It would look like this:

    <Vehicles>
    <Vehicle>
    <lat>35.3738301</lat>
    <lng>-97.1908954</lng>
    <speed>0</speed>
    <heading>0</heading>
    <time>12/2/2006 1:42:30 AM</time>
    </Vehicle>
    <Vehicle>
    <lat>35.3838409</lat>
    <lng>-97.1908963</lng>
    <speed>45</speed>
    <heading>180</heading>
    <time>12/2/2006 1:42:30 AM</time>
    </Vehicle>
    </Vehicles>
  • hi did you ever find a solution to this problem

  • Hi,

    .ASPX file itself is not an XML. When you run it, it can produce XML as its output (as in your example). What sergey is saying is, that for some reason instead of the result fo the execution of your ASPX file (which would be an XML) the ASPX file itself is being parsed by the parser. And that fails (as expected).

    This is probably caused by a misconfiguration of the webserver serving the ASPX files (must be set to execute those and not serve them as a content file).

    Thanks,

  • I figured of this would be a problem with IIS and went to

    Finally I got it fixed this is what I did.

    Start -> settings -> control panel -> Add Remove Programs
    Selected Add Widows components
    Unchecked Internet Information Server (IIS)
    and clicked on  next to uninstall it

    Once I was uninstalled i followed the same process. This timed checked iis insted of
    uncheck to re install iis

    Start -> settings -> control panel -> Add Remove Programs
    Selected Add Widows components
    Checked Internet Information Server (IIS)
    and clicked on  next

    Again registered .net with iis

    Read More.

    http://muruganad.com/ASP.NET/XML-Parsing-Error-not-well-formed.html

    Thanks!
      Murugan
    www.muruganad.com

    • Edited by

      Tuesday, September 8, 2009 9:52 PM

  • This Doesn’t help I still get the error in vs 2008 of

    XML Parsing Error: syntax error
    Location: file:///C:/Users/Matthew.Matthew-PC/Documents/Visual%20Studio%202008/Projects/Go%204%20Ward/special.aspx
    Line Number 1, Column 1:This is a marker file generated by the precompilation tool, and should not be deleted!
    ^

  • I recently encountered this issue and it was solved very easy for me. I encountered it to due to a VS2008 Web Deployment Project. I marked for it to create a virtual directory however under the virtual directory settings it did not have a version of ASP.NET selected. Changing this in IIS fixed this occurrence for me.

    InetMGR

    Right click virtual directory < Properties

    ASP.NET

    Change drop down as appropriate.

    • Proposed as answer by
      Chris Marisic
      Monday, September 21, 2009 5:34 PM
    • Edited by
      Chris Marisic
      Monday, September 21, 2009 5:35 PM
      spelling
  • This Doesn’t help I still get the error in vs 2008 of

    XML Parsing Error: syntax error
    Location: file:///C:/Users/Matthew.Matthew-PC/Documents/Visual%20Studio%202008/Projects/Go%204%20Ward/special.aspx
    Line Number 1, Column 1:This is a marker file generated by the precompilation tool, and should not be deleted!
    ^

    You are loading an .aspx file from the file system. Load it over HTTP from a web server where ASP.NET is installed then it will work. With Visual Studio you have a development server or you can use IIS.


    MVP XML
    My blog

  • Not sure if you figured out this problem yet but try the following solution.

    Click on Start ->Run and type in the following command if you are using .NET 2.0 framework:
    %Windir%Microsoft.NETFrameworkv2.0.50727aspnet_regiis -i

    Once done the .NET Framework will be reinstalled. Your problem had to do with the fact that you no doubt installed the IIS after installing the .NET Framework. If the .NET Framework is not registered with IIS then it will not parse it properly.

  • Thank you. Reinstalling .NET 2.0 solved the issue.

Zorro

Guest
  • #1

XML parser error 4: not well-formed при использовании xslt_process()

Здраствуйте!
Решил я постичь связку XML+XSLT и буквально сразу наткнулся на такую вот неприятность: скрипт выдает ошибку «XML parser error 4: not well-formed (invalid token)».

PHP:

$dir=$_SERVER["DOCUMENT_ROOT"]."/xslt/";
$xsltr=xslt_create();
xslt_set_base($xsltr,"file://$dir");
$result=xslt_process($xsltr,"data.xml","style.xsl");
if($result){
 echo "Parsing completen";
}else{
 echo "Error during parsing: ".xslt_error($xsltr)."n";
}

data.xml:

Код:

<?xml version="l.0"?>
<stuff>
	<todo>First</todo>
	<todo>Second</todo>
	<todo>Third</todo>
	<todo>Fourth</todo>
	<todo>Fith</todo>
	<todo>Sixth</todo>
</stuff>

style.xsl:

Код:

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
				xmlns="http://www.w3.org/TR/xhtml1/strict">
<xsl:strip-space elements="stuff"/>
<xsl:output method="xml"/>
<xsl:template match="todo">
  <xsl:for-each select="stuff">
    <xsl:sort select="."/>
    <p>
      <xsl:number value="position()" format="1. "/>
      <xsl:value-of select="."/>
    </p>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Может есть какие-нибудь догадки?

  • #2

Re: XML parser error 4: not well-formed при использовании xslt_process()

!

Zorro

Guest
  • #3

Re: Re: XML parser error 4: not well-formed при использовании xslt_process()

Автор оригинала: matross
Ты забыл назвать платформу, но судя по всему это windows…

да — она. и Apache/2.0.46 (Win32) PHP/4.3.9

Помоему, вместо этого нуно писать
$dir = ‘file://’ . getcwd () . ‘/’;
потому что $_SERVER[«DOCUMENT_ROOT»] возвращает полный путь от apache servic’a, а тебе нуно полній путь от самого начала… Могу ошибаться, но попробуй….

Попробовал — никаких сдвигов…
Судя по ошибке — дело гдето в XML… Только там негде — файл до убогого прост…

  • #4

говоришь:

<xsl:eek:utput method=»xml»/>

а реально на выходе, судя по исходнику, получается что-то, не имеющее DocumentElement…

Zorro

Guest
  • #5

Автор оригинала: chameleon
говоришь:

а реально на выходе, судя по исходнику, получается что-то, не имеющее DocumentElement…

Убрал — усе тоже самое….

Код:

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
				xmlns="http://www.w3.org/TR/xhtml1/strict">
<xsl:strip-space elements="stuff"/>
<xsl:template match="todo">
  <xsl:for-each select="stuff">
    <xsl:sort select="."/>
    <p>
      <xsl:number value="position()" format="1. "/>
      <xsl:value-of select="."/>
    </p>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

  • #6

Убрал — усе тоже самое….

и что? :)…к RTFM тебя отправить? какой метод используется по-умолчанию? правильно, xml.
не убирать надо а добавлять:

PHP:

<xsl:template match="todo">
<div>
  <xsl:for-each select="stuff">
    <xsl:sort select="."/>
    <p>
      <xsl:number value="position()" format="1. "/>
      <xsl:value-of select="."/>
    </p>
  </xsl:for-each>
</div>
</xsl:template>

Zorro

Guest
  • #8

chameleon
Сделал усе как Вы посоветовали, но результат упорно не хочет меняться…..

И на RTFM сходил — нет там ничего про XSLT

  • #9

а вообще, в IE или Gecko, например, оба файла (xml & xslt) по-отдельности открываются без ошибок? деревья красивые рисуются?

-~{}~ 03.06.05 00:52:

olpa
глаз-алмаз, однако :)

Zorro

Guest
  • #10

Автор оригинала: chameleon
а вообще, в IE или Gecko, например, оба файла (xml & xslt) по-отдельности открываются без ошибок? деревья красивые рисуются?

xslt и там и тут нормально рисуется, а вот xml и в IE и в Firefox 1.0.4 вызывает ошибку….
IE:

Код:

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


--------------------------------------------------------------------------------

Ошибочный номер версии. Ошибка при обработке ресурса ''http://localhost/xslt/data.xml''. Строка 1,Положение 16 

<?xml version="l.0"?>
---------------^

Firefox:

Код:

Ошибка синтаксического анализа XML: ошибка синтаксиса
Адрес: [url]http://localhost/xslt/data.xml[/url]
Строка номер 1, символ 16:<?xml version="l.0"?>
---------------^

  • #11

ну так замени уже «эль» на «единицу»…

-~{}~ 03.06.05 01:19:

или ты не видел, чего тебе olpa написал? :)..

Zorro

Guest
  • #12

Автор оригинала: chameleon
ну так замени уже «эль» на «единицу»…

-~{}~ 03.06.05 01:19:

Заменил — та же фигня…
И это не «эль», а «единица»

  • #13

К таким кардинальным заменам я еще не готов

без шуток, он тебе тоже самое показал — реальная опечатка в атрибуте @version.

какая та же? в браузерах открывается теперь без ошибок?

Zorro

Guest
  • #14

Автор оригинала: chameleon
без шуток, он тебе тоже самое показал — реальная опечатка в атрибуте @version.

какая та же? в браузерах открывается теперь без ошибок?

с теми же самыми ошибками…. Но! Я добавил атрибут @encoding

Код:

<?xml version="1.0" encoding="windows-1251"?>

и браузеры теперь отображают корректно. А вот скрипт по-прежнему выдает ошибку :(

-~{}~ 03.06.05 01:10:

Хм… Вопщем все заработало. Дело было….страшно сказать… в путях… Я явно задал путь для xslt_set_base() и теперь все ок.
Вот он — рабочий пример! :)

PHP:

$dir="D:/Apache/Apache2/wwwdocs/xslt/";
$xsltr=xslt_create();
xslt_set_base($xsltr,"file://$dir");
$result=xslt_process($xsltr,"data.xml","style.xsl","res.html");
if($result){
 echo "Parsing completen";
}else{
 echo "Error during parsing: ".xslt_error($xsltr)."n";
}

Спасибо всем за помощьсочуствие! Отдельное спасибо chameleon

Most severe error I ever had and my methods to work around it, don´t work.

Installed maybe 10 new modules (I have near 250) and updated a few like a suspicious one wysiwyg_imageupload from the 1 to the 2 series.

Suspicious, because it talked about about possible problems upgrading. But the other 10 modules are maybe even more likely to have caused the problem.

update.php worked and resulted in two new tables for wysiwyg_imageupload 2 series.

But then my site was gone and instead «XML Parsing Error: not well-formed», this happened after ticking the new modules on the page
…/admin/build/module

After time, I have learned that if I hit the escape button quickly on loading, I can still see my contents, but without the left and right colomn.

The error message that follows has nothing to do with the real problem; if I rename that module in question with a dot in front (so the module is not recognized anymore), another error shows up from another module (after 4 modules who gave error message after each other, I gave up this method). Also renaming/deactivating the 10 installed modules didn´t work. This always worked before as a bypass when a new module resulted in a problem. Loading the old 1 series wysiwyg_imageupload didn´t work, nor deactivating that module.

I looked on google and drupal for the error message «XML Parsing Error: not well-formed», but couldnt find a general explanation what it means and the specific explanations about certain modules like xmlsitemap, didn´t seem to be involved. I de-activated them too without any result.

I give here my latest error message that I can see on the main page when I quickly hit the escape button before the page is fully loaded, But I suspect that none of the error messages has something to do with the later xml parse error. But to be sure I give them here:

# user warning: Table 'mysite_alba.albapm_block_user' doesn't exist
query: SELECT recipient FROM albapm_block_user WHERE author = 1 AND recipient IN (0) GROUP BY recipient in .../sites/all/modules/privatemsg/pm_block_user/pm_block_user.module on line 183.
(above warning was repeated another 4 times)
#   warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'ctools_access_menu' was given in .../includes/menu.inc on line 452.
(above warning was repeated another 3 times)
#   warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'context_blocks' was given in .../includes/theme.inc on line 656.
(above warning was repeated another 10 times)

That indymedia_alba has some database errors before with new modules, but not resulting in real site problems.
Context probably gives errors, because I de-activated it after de-activating ctools or another module that first gave an error that then changed in an error for context.
Activated/renamed back again context => now nothing will load anymore and immediately get this message:

Fatal error: Call to undefined function ctools_include() in .../sites/all/modules/context/context.module on line 443
array(4) { ["type"]=> int(1) ["message"]=> string(44) "Call to undefined function ctools_include()" ["file"]=> string(74) ".../sites/all/modules/context/context.module" ["line"]=> int(443) } 

OK, activate/renamed ctools again:
Now the left and right column also load, before getting «»
the error messages before the screen wenmt away, were:

# user warning: Table 'mysite_alba.albapm_block_user' doesn't exist
query: SELECT recipient FROM albapm_block_user WHERE author = 1 AND recipient IN (0) GROUP BY recipient in .../sites/all/modules/privatemsg/pm_block_user/pm_block_user.module on line 183.
(above warning was repeated another 3 times)
#   warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'imce_access' was given in .../includes/menu.inc on line 452.
(above warning was repeated another 2 times)

Next to understanding what has happened and what means XML parsing error: Any idea how to get the site back working again?

(otherwise I reinstall everything and copy the only 20 articles back out of the MySQL database)

When loading and saving XML data using FromXml() and ToXml() in C++, the data should be in the local C++ code page. If this is not the case then you may get the error ‘Error — not well-formed (invalid token) at line x’.

This may be resolved by building the application as Unicode, or by using FromXmlStream() and ToXmlStream() which deal with Binary Data and converting the data yourself.

XML Encoding

Xml documents can be encoded using a number of different encodings. The type of encoding is indicated using the encoding tag in the document header (i.e. <?xml version=»1.0″ encoding=»UTF-8″?>).

Writing an XML document to file

When an XML document is persisted as a file, it is safer to consider it in terms as of a stream of bytes as opposed to stream of characters. When an XML document is serialized to a file, an encoding is applied to it. The resulting file will then be correctly encoded given the encoding applied.

  • If a Unicode encoding is applied, the resulting file is prefixed with the Unicode header 0xFF 0xFE, and will be encoded with 2 bytes per character.
  • If a UTF-8 encoding is applied the resulting file will contain a variable number of bytes per character. If this file is then viewed using a tool incapable of decoding UTF-8, then you may see it contains a number of strange characters. If the file is viewed using an UTF-8 compliant application (e.g. IExplorer, Notepad on Win2000 onwards, Visual Studio .Net) then the XML Document will appear with the correct characters (if characters are corrupted or misrepresented, it should be noted that some fonts do not contain the full UNICODE set)

Turning an XML document a string

When an XML document is created from a generated class using ToXml (ToXml returns a string). The string returned is encoded as Unicode (except in C++ non-debug builds), however the XML document header does not show any encoding (<?xml version=»1.0″?>).

The string returned is Unicode, Unicode is the internal character representation for VB6, .Net & Java, as such if it is written to file or passed to another application, it should be passed as Unicode. If it has to be converted to a 1 byte per character representation prior to this, then data will likely be corrupted if complex characters have been used within the document.

If you need to persist an XML document to a file use ToXmlFile, if you need pass an XML document to another (non-Unicode) application, then should use ToXmlStream.

There is also a problem that commonly occurs in C++ UNICODE applications when dealing with UTF-8 encoded data. If you load a UFT-8 encoded file into a UNICODE application, the temptation is to store it in a UNICODE string (WCHAR*), and the conversion to Unicode is often implicit (part of some string/bstr class). However these conversions typically assume the source string is in the local code page, which is rarely UTF-8, and more frequently ANSI. So when the data is converted to UNICODE, the conversion function does not treat the data as UTF-8, and so does not correctly decode it. This results in a UNICODE string which no longer represents the source.

In these circumstances, it is better to either treat the data as binary or to use the appropriate conversion method — utf8 to Unicode.

Passing an XML document to a ASCII or ANSI application

It is common to want to pass the XML document you have created to a non-Unicode application. If you need to do this then you may look first at ToXml, this will provide you with a UNICODE string, however converting this to an ASCII or ANSI string may cause the corruption of complex characters (you lose information going from 2 bytes to 1 byte per character). You could take the string returned from ToXml, and apply your own UTF-8 encoding, however the encoding attribute in the header (<?xml version=»1.0″ encoding=»UTF-8″?>) would not be present, and the XML parser decoding the document may misinterpret it.

The better solution is to use the ToXmlStream method. This allows you to specify an encoding, and returns a stream of bytes (array of bytes in VB). This byte stream is a representation of the XML Document in the given encoding, containing the correct encoding attribute in the header (<?xml version=»1.0″ encoding=»UTF-8″?>).

Article ID: 87, Created: 3/20/2012 at 11:24 AM, Modified: 3/20/2012 at 11:24 AM

I’ve come across another APK that’s suffering from this issue:

Information

Apktool Version: 2.2.2
Operating System: Both Linux and Mac
APK From: https://forum.xda-developers.com/android/apps-games/ps4-remote-play-android-thread-t3068225

Steps to Reproduce

$ apktool d RemotePlayPortV5.1_ITB.apk
...
$ apktool b RemotePlayPortV5.1_ITB

I: Using Apktool 2.2.2 on RemotePlayPortV5.1_ITB.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /root/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
root@99033f046f3d:/usr/src/apk# apktool b RemotePlayPortV5.1_ITB
I: Using Apktool 2.2.2
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
W: /usr/src/apk/RemotePlayPortV5.1_ITB/res/layout/companionutil_layout_alert_dialog.xml:2: error: Error parsing XML: not well-formed (invalid token)
W:
W: /usr/src/apk/RemotePlayPortV5.1_ITB/res/layout/companionutil_layout_alert_dialog_game2_confirm.xml:2: error: Error parsing XML: not well-formed (invalid token)
W:
W: /usr/src/apk/RemotePlayPortV5.1_ITB/res/layout/companionutil_layout_alert_dialog_game_confirm.xml:2: error: Error parsing XML: not well-formed (invalid token)
W:
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_4284272564605293496.tmp, p, --forced-package-id, 127, --min-sdk-version, 17, --target-sdk-version, 19, --version-code, 10500, --version-name, 1.5.0, --no-version-vectors, -F, /tmp/APKTOOL6062192940819296925.tmp, -0, arsc, -0, arsc, -I, /root/.local/share/apktool/framework/1.apk, -S, /usr/src/apk/RemotePlayPortV5.1_ITB/res, -M, /usr/src/apk/RemotePlayPortV5.1_ITB/AndroidManifest.xml]
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:477)
	at brut.androlib.Androlib.buildResources(Androlib.java:411)
	at brut.androlib.Androlib.build(Androlib.java:310)
	at brut.androlib.Androlib.build(Androlib.java:263)
	at brut.apktool.Main.cmdBuild(Main.java:227)
	at brut.apktool.Main.main(Main.java:84)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_4284272564605293496.tmp, p, --forced-package-id, 127, --min-sdk-version, 17, --target-sdk-version, 19, --version-code, 10500, --version-name, 1.5.0, --no-version-vectors, -F, /tmp/APKTOOL6062192940819296925.tmp, -0, arsc, -0, arsc, -I, /root/.local/share/apktool/framework/1.apk, -S, /usr/src/apk/RemotePlayPortV5.1_ITB/res, -M, /usr/src/apk/RemotePlayPortV5.1_ITB/AndroidManifest.xml]
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:440)
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:463)
	... 5 more
Caused by: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_4284272564605293496.tmp, p, --forced-package-id, 127, --min-sdk-version, 17, --target-sdk-version, 19, --version-code, 10500, --version-name, 1.5.0, --no-version-vectors, -F, /tmp/APKTOOL6062192940819296925.tmp, -0, arsc, -0, arsc, -I, /root/.local/share/apktool/framework/1.apk, -S, /usr/src/apk/RemotePlayPortV5.1_ITB/res, -M, /usr/src/apk/RemotePlayPortV5.1_ITB/AndroidManifest.xml]
	at brut.util.OS.exec(OS.java:95)
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:434)
	... 6 more

Example invalid .xml:

<?xml version="1.0" encoding="utf-8"?>
<o.ﺗ android:layout_gravity="center" android:orientation="vertical" android:background="@drawable/companionutil_drawable_alert_dialog" android:layout_width="fill_parent" android:layout_height="wrap_content" landscape_marginLeft="33dp" landscape_marginRight="33dp" portrait_marginLeft="11dp" portrait_marginRight="11dp"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <com.playstation.companionutil.CompanionUtilAdjustTextView android:textSize="16.0dip" android:textColor="#ffffffff" android:id="@id/com_playstation_companionutil_id_alert_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="11.0dip" android:layout_marginTop="17.0dip" android:layout_marginRight="11.0dip" android:text="" android:lineSpacingExtra="1.0dip" />
    <com.playstation.companionutil.CompanionUtilAdjustButton android:textSize="16.0dip" android:textColor="#ffffffff" android:id="@id/com_playstation_companionutil_id_alert_positive_button" android:background="@drawable/companionutil_drawable_alert_dialog_button" android:layout_width="fill_parent" android:layout_height="28.0dip" android:layout_marginLeft="11.0dip" android:layout_marginTop="15.0dip" android:layout_marginRight="11.0dip" android:layout_marginBottom="15.0dip" android:text="@string/com_playstation_companionutil_msg_ok" />
</o.ﺗ>

APK

PS4 Remote Play Port
(https://forum.xda-developers.com/android/apps-games/ps4-remote-play-android-thread-t3068225)

Questions to ask before submission

Have you tried apktool d, apktool b without changing anything? Yes
If you are trying to install a modified apk, did you resign it? No
Are you using the latest apktool version? Yes

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