mpsn Posted February 6, 2012 Share Posted February 6, 2012 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> Quote Link to comment https://forums.phpfreaks.com/topic/256552-multiple-text-nodes-for-a-parent-node/ Share on other sites More sharing options...
kicken Posted February 6, 2012 Share Posted February 6, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/256552-multiple-text-nodes-for-a-parent-node/#findComment-1315220 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.