Lesson 2

Syntax and Namespaces

Well-formed XML and xmlns patterns.

Well-formed XML requires matched tags, quoted attributes, and exactly one root element. Common parse errors come from unclosed tags, & without escaping, or mismatched nesting after copy-paste.

Namespaces

Real project files declare XML namespaces so tag names from different specs do not collide:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  <application android:label="@string/app_name" />
</manifest>

The xmlns:android prefix maps android:* attributes to Android's schema URI. Formatting does not change namespace semantics—it only makes structure easier to read.

Comments and declarations

  • <?xml version="1.0" encoding="UTF-8"?> — optional prolog
  • <!-- comment --> — may be removed or moved when reformatting; keep backups if comments matter

Key takeaway

Focus on matching tags and valid escaping first. Namespace prefixes are part of the syntax you validate before build tools run.

When you want to practice, use the related DevCove tool — optional, not part of this lesson.

Open related tool

Back to course overview