[{"data":1,"prerenderedAt":650},["ShallowReactive",2],{"guide-xml-namespaces-explained":3},{"id":4,"title":5,"body":6,"date":642,"description":643,"extension":644,"meta":645,"navigation":172,"path":646,"readingTime":121,"seo":647,"stem":648,"__hash__":649},"guides\u002Fguides\u002Fxml-namespaces-explained.md","XML Namespaces Explained",{"type":7,"value":8,"toc":628},"minimark",[9,14,23,34,38,45,74,85,90,93,125,136,140,143,191,205,209,215,245,260,267,292,296,299,328,364,367,382,386,389,419,429,433,543,551,555,587,591,611,615,624],[10,11,13],"h2",{"id":12},"why-namespaces-exist","Why Namespaces Exist",[15,16,17,18,22],"p",{},"XML lets you define your own element names. That freedom creates collisions when you combine documents from different sources. Two ",[19,20,21],"code",{},"\u003Ctitle>"," elements might mean completely different things — a book title versus a job title.",[15,24,25,26,29,30,33],{},"Namespaces solve this by attaching a URI to element and attribute names, making them globally unique. ",[19,27,28],{},"\u003Cbook:title>"," and ",[19,31,32],{},"\u003Cjob:title>"," are now distinct, even though the local name is the same.",[10,35,37],{"id":36},"the-namespace-declaration","The Namespace Declaration",[15,39,40,41,44],{},"Namespaces are declared with the ",[19,42,43],{},"xmlns"," attribute:",[46,47,52],"pre",{"className":48,"code":49,"language":50,"meta":51,"style":51},"language-xml shiki shiki-themes github-light github-dark","\u003Cbook xmlns=\"http:\u002F\u002Fexample.com\u002Fbook\">\n  \u003Ctitle>XML Basics\u003C\u002Ftitle>\n\u003C\u002Fbook>\n","xml","",[19,53,54,62,68],{"__ignoreMap":51},[55,56,59],"span",{"class":57,"line":58},"line",1,[55,60,61],{},"\u003Cbook xmlns=\"http:\u002F\u002Fexample.com\u002Fbook\">\n",[55,63,65],{"class":57,"line":64},2,[55,66,67],{},"  \u003Ctitle>XML Basics\u003C\u002Ftitle>\n",[55,69,71],{"class":57,"line":70},3,[55,72,73],{},"\u003C\u002Fbook>\n",[15,75,76,77,80,81,84],{},"This applies the namespace ",[19,78,79],{},"http:\u002F\u002Fexample.com\u002Fbook"," to the ",[19,82,83],{},"\u003Cbook>"," element and all its descendants — unless overridden by another declaration.",[86,87,89],"h3",{"id":88},"prefixed-namespaces","Prefixed Namespaces",[15,91,92],{},"When you need multiple namespaces in one document, use prefixes:",[46,94,96],{"className":48,"code":95,"language":50,"meta":51,"style":51},"\u003Ccatalog xmlns:book=\"http:\u002F\u002Fexample.com\u002Fbook\"\n         xmlns:job=\"http:\u002F\u002Fexample.com\u002Fjob\">\n  \u003Cbook:title>XML Basics\u003C\u002Fbook:title>\n  \u003Cjob:title>Senior Developer\u003C\u002Fjob:title>\n\u003C\u002Fcatalog>\n",[19,97,98,103,108,113,119],{"__ignoreMap":51},[55,99,100],{"class":57,"line":58},[55,101,102],{},"\u003Ccatalog xmlns:book=\"http:\u002F\u002Fexample.com\u002Fbook\"\n",[55,104,105],{"class":57,"line":64},[55,106,107],{},"         xmlns:job=\"http:\u002F\u002Fexample.com\u002Fjob\">\n",[55,109,110],{"class":57,"line":70},[55,111,112],{},"  \u003Cbook:title>XML Basics\u003C\u002Fbook:title>\n",[55,114,116],{"class":57,"line":115},4,[55,117,118],{},"  \u003Cjob:title>Senior Developer\u003C\u002Fjob:title>\n",[55,120,122],{"class":57,"line":121},5,[55,123,124],{},"\u003C\u002Fcatalog>\n",[15,126,127,128,131,132,135],{},"The prefix is a shorthand — the XML parser replaces ",[19,129,130],{},"book:title"," with ",[19,133,134],{},"{http:\u002F\u002Fexample.com\u002Fbook}title"," internally. The prefix name itself is irrelevant; only the URI matters.",[10,137,139],{"id":138},"the-uri-vs-the-prefix","The URI vs. the Prefix",[15,141,142],{},"A common misconception: the namespace URI does not need to point to a real web page. It is an identifier, not a link.",[46,144,146],{"className":48,"code":145,"language":50,"meta":51,"style":51},"\u003C!-- These are the SAME namespace — same URI, different prefixes -->\n\u003Cdoc xmlns:a=\"http:\u002F\u002Fexample.com\u002Fns\">\n  \u003Ca:item>Hello\u003C\u002Fa:item>\n\u003C\u002Fdoc>\n\n\u003Cdoc xmlns:b=\"http:\u002F\u002Fexample.com\u002Fns\">\n  \u003Cb:item>Hello\u003C\u002Fb:item>\n\u003C\u002Fdoc>\n",[19,147,148,153,158,163,168,174,180,186],{"__ignoreMap":51},[55,149,150],{"class":57,"line":58},[55,151,152],{},"\u003C!-- These are the SAME namespace — same URI, different prefixes -->\n",[55,154,155],{"class":57,"line":64},[55,156,157],{},"\u003Cdoc xmlns:a=\"http:\u002F\u002Fexample.com\u002Fns\">\n",[55,159,160],{"class":57,"line":70},[55,161,162],{},"  \u003Ca:item>Hello\u003C\u002Fa:item>\n",[55,164,165],{"class":57,"line":115},[55,166,167],{},"\u003C\u002Fdoc>\n",[55,169,170],{"class":57,"line":121},[55,171,173],{"emptyLinePlaceholder":172},true,"\n",[55,175,177],{"class":57,"line":176},6,[55,178,179],{},"\u003Cdoc xmlns:b=\"http:\u002F\u002Fexample.com\u002Fns\">\n",[55,181,183],{"class":57,"line":182},7,[55,184,185],{},"  \u003Cb:item>Hello\u003C\u002Fb:item>\n",[55,187,189],{"class":57,"line":188},8,[55,190,167],{},[15,192,193,194,29,197,200,201,204],{},"Both ",[19,195,196],{},"\u003Ca:item>",[19,198,199],{},"\u003Cb:item>"," expand to ",[19,202,203],{},"{http:\u002F\u002Fexample.com\u002Fns}item",". The parser treats them as identical.",[10,206,208],{"id":207},"default-namespace","Default Namespace",[15,210,211,212,214],{},"An ",[19,213,43],{}," declaration without a prefix sets the default namespace for the element and its descendants:",[46,216,218],{"className":48,"code":217,"language":50,"meta":51,"style":51},"\u003Ctable xmlns=\"http:\u002F\u002Fwww.w3.org\u002F1999\u002Fxhtml\">\n  \u003Ctr>\n    \u003Ctd>Data cell\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n",[19,219,220,225,230,235,240],{"__ignoreMap":51},[55,221,222],{"class":57,"line":58},[55,223,224],{},"\u003Ctable xmlns=\"http:\u002F\u002Fwww.w3.org\u002F1999\u002Fxhtml\">\n",[55,226,227],{"class":57,"line":64},[55,228,229],{},"  \u003Ctr>\n",[55,231,232],{"class":57,"line":70},[55,233,234],{},"    \u003Ctd>Data cell\u003C\u002Ftd>\n",[55,236,237],{"class":57,"line":115},[55,238,239],{},"  \u003C\u002Ftr>\n",[55,241,242],{"class":57,"line":121},[55,243,244],{},"\u003C\u002Ftable>\n",[15,246,247,248,251,252,255,256,259],{},"Here ",[19,249,250],{},"\u003Ctable>",", ",[19,253,254],{},"\u003Ctr>",", and ",[19,257,258],{},"\u003Ctd>"," are in the XHTML namespace. No prefix needed.",[15,261,262,266],{},[263,264,265],"strong",{},"To switch back to no namespace",", declare an empty default namespace:",[46,268,270],{"className":48,"code":269,"language":50,"meta":51,"style":51},"\u003Cdocument xmlns=\"http:\u002F\u002Fexample.com\u002Fdoc\">\n  \u003Csection>Namespaced content\u003C\u002Fsection>\n  \u003Craw xmlns=\"\">Unnamespaced content\u003C\u002Fraw>\n\u003C\u002Fdocument>\n",[19,271,272,277,282,287],{"__ignoreMap":51},[55,273,274],{"class":57,"line":58},[55,275,276],{},"\u003Cdocument xmlns=\"http:\u002F\u002Fexample.com\u002Fdoc\">\n",[55,278,279],{"class":57,"line":64},[55,280,281],{},"  \u003Csection>Namespaced content\u003C\u002Fsection>\n",[55,283,284],{"class":57,"line":70},[55,285,286],{},"  \u003Craw xmlns=\"\">Unnamespaced content\u003C\u002Fraw>\n",[55,288,289],{"class":57,"line":115},[55,290,291],{},"\u003C\u002Fdocument>\n",[10,293,295],{"id":294},"attributes-and-namespaces","Attributes and Namespaces",[15,297,298],{},"Attributes behave differently from elements:",[46,300,302],{"className":48,"code":301,"language":50,"meta":51,"style":51},"\u003Cbook xmlns=\"http:\u002F\u002Fexample.com\u002Fbook\"\n      id=\"123\"\n      xml:lang=\"en\">\n  \u003Ctitle>XML Namespaces\u003C\u002Ftitle>\n\u003C\u002Fbook>\n",[19,303,304,309,314,319,324],{"__ignoreMap":51},[55,305,306],{"class":57,"line":58},[55,307,308],{},"\u003Cbook xmlns=\"http:\u002F\u002Fexample.com\u002Fbook\"\n",[55,310,311],{"class":57,"line":64},[55,312,313],{},"      id=\"123\"\n",[55,315,316],{"class":57,"line":70},[55,317,318],{},"      xml:lang=\"en\">\n",[55,320,321],{"class":57,"line":115},[55,322,323],{},"  \u003Ctitle>XML Namespaces\u003C\u002Ftitle>\n",[55,325,326],{"class":57,"line":121},[55,327,73],{},[329,330,331,342,355],"ul",{},[332,333,334,337,338,341],"li",{},[19,335,336],{},"id"," — ",[263,339,340],{},"Not"," in any namespace. Unprefixed attributes are always in no namespace, even when the element has a default namespace.",[332,343,344,347,348,350,351,354],{},[19,345,346],{},"xml:lang"," — In the built-in ",[19,349,50],{}," namespace (",[19,352,353],{},"http:\u002F\u002Fwww.w3.org\u002FXML\u002F1998\u002Fnamespace",").",[332,356,357,360,361,363],{},[19,358,359],{},"title"," — In the default namespace ",[19,362,79],{},".",[15,365,366],{},"This is a frequent source of confusion. To put an attribute in a namespace, you must use a prefix:",[46,368,370],{"className":48,"code":369,"language":50,"meta":51,"style":51},"\u003Cbook xmlns:isbn=\"http:\u002F\u002Fexample.com\u002Fisbn\"\n      isbn:number=\"978-0123456789\">\n",[19,371,372,377],{"__ignoreMap":51},[55,373,374],{"class":57,"line":58},[55,375,376],{},"\u003Cbook xmlns:isbn=\"http:\u002F\u002Fexample.com\u002Fisbn\"\n",[55,378,379],{"class":57,"line":64},[55,380,381],{},"      isbn:number=\"978-0123456789\">\n",[10,383,385],{"id":384},"namespace-scope","Namespace Scope",[15,387,388],{},"Namespace declarations apply to the element where they are declared and all descendants. Child elements can override:",[46,390,392],{"className":48,"code":391,"language":50,"meta":51,"style":51},"\u003Croot xmlns=\"http:\u002F\u002Fexample.com\u002Fdefault\">\n  \u003Cchild>Default namespace\u003C\u002Fchild>\n  \u003Cchild xmlns=\"http:\u002F\u002Fexample.com\u002Fother\">Different namespace\u003C\u002Fchild>\n  \u003Cchild>Back to default namespace\u003C\u002Fchild>\n\u003C\u002Froot>\n",[19,393,394,399,404,409,414],{"__ignoreMap":51},[55,395,396],{"class":57,"line":58},[55,397,398],{},"\u003Croot xmlns=\"http:\u002F\u002Fexample.com\u002Fdefault\">\n",[55,400,401],{"class":57,"line":64},[55,402,403],{},"  \u003Cchild>Default namespace\u003C\u002Fchild>\n",[55,405,406],{"class":57,"line":70},[55,407,408],{},"  \u003Cchild xmlns=\"http:\u002F\u002Fexample.com\u002Fother\">Different namespace\u003C\u002Fchild>\n",[55,410,411],{"class":57,"line":115},[55,412,413],{},"  \u003Cchild>Back to default namespace\u003C\u002Fchild>\n",[55,415,416],{"class":57,"line":121},[55,417,418],{},"\u003C\u002Froot>\n",[15,420,421,422,425,426,428],{},"Each ",[19,423,424],{},"\u003Cchild>"," element's namespace is determined by the closest ",[19,427,43],{}," declaration going up the tree.",[10,430,432],{"id":431},"common-namespace-urls","Common Namespace URLs",[434,435,436,452],"table",{},[437,438,439],"thead",{},[440,441,442,446,449],"tr",{},[443,444,445],"th",{},"Prefix",[443,447,448],{},"URI",[443,450,451],{},"Used For",[453,454,455,469,483,498,513,528],"tbody",{},[440,456,457,462,466],{},[458,459,460],"td",{},[19,461,50],{},[458,463,464],{},[19,465,353],{},[458,467,468],{},"Built-in XML attributes (lang, space, base)",[440,470,471,475,480],{},[458,472,473],{},[19,474,43],{},[458,476,477],{},[19,478,479],{},"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fxmlns\u002F",[458,481,482],{},"Namespace declarations themselves",[440,484,485,490,495],{},[458,486,487],{},[19,488,489],{},"xsi",[458,491,492],{},[19,493,494],{},"http:\u002F\u002Fwww.w3.org\u002F2001\u002FXMLSchema-instance",[458,496,497],{},"Schema-related attributes (type, nil, schemaLocation)",[440,499,500,505,510],{},[458,501,502],{},[19,503,504],{},"xsl",[458,506,507],{},[19,508,509],{},"http:\u002F\u002Fwww.w3.org\u002F1999\u002FXSL\u002FTransform",[458,511,512],{},"XSLT stylesheets",[440,514,515,520,525],{},[458,516,517],{},[19,518,519],{},"svg",[458,521,522],{},[19,523,524],{},"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg",[458,526,527],{},"SVG graphics",[440,529,530,535,540],{},[458,531,532],{},[19,533,534],{},"xhtml",[458,536,537],{},[19,538,539],{},"http:\u002F\u002Fwww.w3.org\u002F1999\u002Fxhtml",[458,541,542],{},"XHTML documents",[15,544,545,546,29,548,550],{},"The ",[19,547,50],{},[19,549,43],{}," prefixes are reserved — you cannot redeclare them.",[10,552,554],{"id":553},"practical-tips","Practical Tips",[329,556,557,563,569,575,581],{},[332,558,559,562],{},[263,560,561],{},"Use default namespace for the dominant vocabulary"," in your document to reduce noise.",[332,564,565,568],{},[263,566,567],{},"Use prefixes for secondary vocabularies"," like metadata or inline elements from other domains.",[332,570,571,574],{},[263,572,573],{},"Never use relative URIs as namespace identifiers"," — they are deprecated and cause interoperability issues.",[332,576,577,580],{},[263,578,579],{},"Be consistent with prefix names"," across your organization, even though the prefix is technically arbitrary.",[332,582,583,586],{},[263,584,585],{},"Remember: unprefixed attributes are never in a namespace",", regardless of the default namespace on the element.",[10,588,590],{"id":589},"key-takeaways","Key Takeaways",[329,592,593,596,599,602,605,608],{},[332,594,595],{},"Namespaces prevent name collisions by pairing local names with URIs",[332,597,598],{},"The prefix is just a shorthand — only the URI matters for identity",[332,600,601],{},"Default namespace applies to elements, never to unprefixed attributes",[332,603,604],{},"Namespace URI does not need to be a real URL — it is an identifier",[332,606,607],{},"Child elements override parent namespace declarations",[332,609,610],{},"Prefixed attributes are the only way to put an attribute in a namespace",[10,612,614],{"id":613},"try-it-yourself","Try It Yourself",[15,616,617,618,623],{},"Format XML documents with proper namespace indentation using our ",[619,620,622],"a",{"href":621},"\u002Ftools\u002Fxml-formatter","XML Formatter",". Paste your XML and see clean, readable output instantly.",[625,626,627],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":51,"searchDepth":64,"depth":64,"links":629},[630,631,634,635,636,637,638,639,640,641],{"id":12,"depth":64,"text":13},{"id":36,"depth":64,"text":37,"children":632},[633],{"id":88,"depth":70,"text":89},{"id":138,"depth":64,"text":139},{"id":207,"depth":64,"text":208},{"id":294,"depth":64,"text":295},{"id":384,"depth":64,"text":385},{"id":431,"depth":64,"text":432},{"id":553,"depth":64,"text":554},{"id":589,"depth":64,"text":590},{"id":613,"depth":64,"text":614},"2026-05-28","Understand XML namespaces — why they exist, how URIs and prefixes work, and the exact rules for default vs prefixed namespaces in elements and attributes.","md",{"immutable":172},"\u002Fguides\u002Fxml-namespaces-explained",{"title":5,"description":643},"guides\u002Fxml-namespaces-explained","8BG4C_q9ZueQEkW4c8MqCljXhGf4hMiCMbFSXMMtY6I",1780401338404]