Stavo leggendo un ebook e ha seguito il codice xml.Qual è il nodo radice in XML?
<?xml version="1.0"?>
<?xml-stylesheet href="sonnet.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>
<!DOCTYPE sonnet [
<!ELEMENT sonnet (auth:author, title, lines)>
<!ATTLIST sonnet public-domain CDATA "yes"
type (Shakespearean | Petrarchan) "Shakespearean">
<!ELEMENT auth:author (last-name,first-name,nationality,
year-of-birth?,year-of-death?)>
<!ELEMENT last-name (#PCDATA)>
<!ELEMENT first-name (#PCDATA)>
<!ELEMENT nationality (#PCDATA)>
<!ELEMENT year-of-birth (#PCDATA)>
<!ELEMENT year-of-death (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT lines (line,line,line,line,
line,line,line,line,line,line,line,
line,line,line)>
<!ELEMENT line (#PCDATA)>
]>
<!-- Default sonnet type is Shakespearean, the other allowable -->
<!-- type is "Petrarchan." -->
<sonnet type="Shakespearean">
<auth:author xmlns:auth="http://www.authors.com/">
<last-name>Shakespeare</last-name>
<first-name>William</first-name>
<nationality>British</nationality>
<year-of-birth>1564</year-of-birth>
<year-of-death>1616</year-of-death>
</auth:author>
<!-- Is there an official title for this sonnet? They're
sometimes named after the first line. -->
<title>Sonnet 130</title>
<lines>
<line>My mistress' eyes are nothing like the sun,</line>
<line>Coral is far more red than her lips red.</line>
<line>If snow be white, why then her breasts are dun,</line>
<line>If hairs be wires, black wires grow on her head.</line>
<line>I have seen roses damasked, red and white,</line>
<line>But no such roses see I in her cheeks.</line>
<line>And in some perfumes is there more delight</line>
<line>Than in the breath that from my mistress reeks.</line>
<line>I love to hear her speak, yet well I know</line>
<line>That music hath a far more pleasing sound.</line>
<line>I grant I never saw a goddess go,</line>
<line>My mistress when she walks, treads on the ground.</line>
<line>And yet, by Heaven, I think my love as rare</line>
<line>As any she belied with false compare.</line>
</lines>
</sonnet>
<!-- The title of Sting's 1987 album "Nothing like the sun" is -->
<!-- from line 1 of this sonnet.
problema è quando io continuo il resto della lettura ho pensato che ho fraintendere ciò che è elemento principale. Secondo il mio nodo root knoweledge è il nodo <sonnet>
.
Ma nel libro che ho Trova successivo questo
A differenza di altri nodi, il nodo principale non ha genitore. Ha sempre a un figlio, l'elemento del documento. Il nodo radice contiene anche i commenti o le istruzioni di elaborazione che si trovano all'esterno dell'elemento documento . Nel nostro documento di esempio, le due istruzioni di elaborazione denominate xmlstylesheet e bozzetto-processo sono entrambi figli del nodo radice, così come il commento visualizzato prima del tag e il commento visualizzato dopo il tag.
conforme all'intero documento è considerato come root. Se sì, cos'è? È chiaro che le istruzioni e i commenti di elaborazione non sono figlio del nodo.
do I minunderstand?
aggiornamento
<?xml version="1.0"?>
<Food>
<Cateogry> Vegetable</Cateogry>
<Cateogry> Fruits</Cateogry>
<Cateogry> other</Cateogry>
</Food>
qual è l'elemento principale qui? non è cibo?
Non confondere "nodo radice" con "elemento radice" o "elemento documento". –