Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. XML element or attribute?

XML element or attribute?

Scheduled Pinned Locked Moved IT & Infrastructure
tutorialquestionxmlperformancehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Dear I have a question about how to use attribute or element. Recently when I desige the XML data map, I am confusing that when should I attribute , when should I use element. For example, I have "Login" root element. Inside the Login, I want to put username and password. So, Should I make an child element "username" and "password"? Or should I put attribute "username" and "password" under the root element "Login"?? Well, it seems not much different between two. But in many case, I always think about Should I use this field for attribute or for child element? Is there any general rules can help me to choose between attribute and element? such as if the data size is large, we should use........etc How does it affect the application performance? regards Davis :confused: Davis Leung Analyst Programmer Fedex

    N 1 Reply Last reply
    0
    • L Lost User

      Dear I have a question about how to use attribute or element. Recently when I desige the XML data map, I am confusing that when should I attribute , when should I use element. For example, I have "Login" root element. Inside the Login, I want to put username and password. So, Should I make an child element "username" and "password"? Or should I put attribute "username" and "password" under the root element "Login"?? Well, it seems not much different between two. But in many case, I always think about Should I use this field for attribute or for child element? Is there any general rules can help me to choose between attribute and element? such as if the data size is large, we should use........etc How does it affect the application performance? regards Davis :confused: Davis Leung Analyst Programmer Fedex

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      No there are no rules for what should be an attribute and what should be an element. It's just up to you to decide what would work better for you application. Generally though an attribute should be one or two words, anything more should be an element. Another thing to consider is how you may need to use document. If for example you have a name element with child elements for first name and last name you could obtain the nodes by first or last name, or just the name nodes. You could do the same thing with attrbutes but not as cleanly in my opinion.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups