Jump to content

multiple text nodes for a parent node


mpsn

Recommended Posts

Hi, I need to build my own xml validator and was wondering, what are some possible purposes of having multiple text nodes for a given parent node, I ask b/c while I was playing around with W3schools XML validator, I noticed it successfully validated the following:

 

<?xml version="1.0" encoding="utf-8" ?>

<note>

<to>Joh</to>

<from>Frank</from>

<body>Hello world</body>

  Extra text node that is validated!

</note>

 

Link to comment
Share on other sites

Every time you put a new line between your tags your making a text node.  There is nothing wrong with having several text nodes within a particular element.  Even having two right next to each other is ok, just typically they get combined together into a single one.

 

Take for example the following HTML which would be something fairly typical.

 

<h2>Hello <a href="profile">kicken</a>, welcome to <a href="phpfreaks">phpfreaks</a>.</h2>

 

That h2 element has three different text nodes.

 

Most xml based formats tend to avoid mixing text and elements such as the above, as it's easier to work with when elements only contain elements, or only contain text.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.