user1592380
user1592380

Reputation: 36247

XML Parsing Error: mismatched tag. Expected: </link>, Django

enter image description here

I am working with a django template. the head of the template is:

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Landing Page - Start Bootstrap Theme</title>

    <!-- Bootstrap Core CSS -->
    {% load staticfiles %}
    <link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="{% static "css/landing-page.css" %}" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="{% static "font-awesome-4.2.0/css/font-awesome.min.css" %}" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

My view contains:

def index(request):
    t = loader.get_template('app1/index.html')
    c = RequestContext(request, {})
    return HttpResponse(t.render(c),content_type="application/xhtml+xml")

How can I fix the error in the screenshot?

Upvotes: 2

Views: 8969

Answers (1)

Andrew Dunai
Andrew Dunai

Reputation: 3129

This is not a valid XML tag:

<link href="{% static "css/landing-page.css" %}" rel="stylesheet">

Instead, it should be:

<link href="{% static "css/landing-page.css" %}" rel="stylesheet" />

This is because, according to XML specs, any tag has to be either closed with its pair or self-closed by including slash (/) at the and of opening tag. Most browsers understand this, but, speaking strictly, this is incorrect.

Also, if you have any <hr>, <br> or similar single tags, you'll have to fix them all as well, i.e. <hr />, <br />

See this list: http://xahlee.info/js/html5_non-closing_tag.html.

Upvotes: 4

Related Questions