XML Child

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

xml tree - child

When a man loves a woman very, very much, sometimes a kid shows up. This kid is the child of the man and woman.

In XML, an element can have many or no children. Element A is the child of element B when:

  • Element A is contained within element B and is exactly one level below element B.

In other words, B is the parent of A. In this example XML document there are three child relationships. Can you find them?

XML Code:

  • Element b is the child of element a.

  • Element c is the child of element b.

  • Element d is the child of element c.


do you know where your children are?

To find the children of element A, look between A's opening and closing tags. If there are elements which are only contained by element A, then they are A's children elements.

Can you find the children elements of chips?

XML Code, lemonade.xml:


price and amount are the children of chips.

If it helps, you can always think of an XML document in a tree structure. Here, we have highlighted the children of chips in our lemonade.xml document.

XML Tree: