Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NameSpaces in XML

 
Krishna Srinivasan
Ranch Hand
Posts: 1876
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

<foo:book xmlns:foo="http://www.books.com/books"
xmlns=""http://www.notes.com/books">
<book1>Name</book1>
<foo:book1>Name</foo:book1>
</foo:book>

Can anyone explain on this code?

the tags book1 and foo:book1 where it refers to?
and give me some explanation about the default namespaces and how it works?

thanx in advance!!
 
Mikalai Zaikin
Ranch Hand
Posts: 3371
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Krishna Srinivasan:
HI,

<foo:book xmlns:foo="http://www.books.com/books"
xmlns=""http://www.notes.com/books">
<book1>Name</book1>
<foo:book1>Name</foo:book1>
</foo:book>

Can anyone explain on this code?

the tags book1 and foo:book1 where it refers to?
and give me some explanation about the default namespaces and how it works?

thanx in advance!!


Hello Krishna !

This line :



declared 2 namespaces:

1. with prefix 'foo' - http://www.books.com/books
2. default, without any prefix - http://www.notes.com/books (I assume double quote is just a typo)

so, *within* the tag where namespaces were declared,
  • book1 - default namespace - belongs to 'http://www.notes.com/books'
  • foo:book1 - 'foo' namespace - belongs to 'http://www.books.com/books'


  • More on namespaces you can find here -
    http://java.boot.by/wsd-guide/ch01s03.html

    regards,
    MZ
     
    Krishna Srinivasan
    Ranch Hand
    Posts: 1876
    Firefox Browser Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you for your reply.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic