Jump to content

Sibling text nodes and white space


Recommended Posts

I'm learning more about the specifics of XML, and I've run into a question.

<root>	<child>Child 1</child>	Text Child	<child>Child 2</child></root>

First, I would like to know if this is even legal. If so, I read that XML parsers should not truncate white space, so in the case of the text node, what white space would it contain?

Link to post
Share on other sites
It is not legal. Only white space can exist between nodes. "Text Child" must be wrapped in tags.
an element can contain mixed content or combination (containing element and text). i think it is legal. is not it? Edited by birbal
Link to post
Share on other sites

Well, parsing an XML string with given content with JavaScript doesn't give me an error. It has two "child" nodes and one text node containing "Text Child" with some form of white space in the front (might be a single space). That's what led me to this question.So, does that mean the parser is parsing incorrectly? I'm trying to make sense of the XML spec, but their notation is hard for me to follow, as I've never seen that sort of notation before.

Link to post
Share on other sites
Well, parsing an XML string with given content with JavaScript doesn't give me an error. It has two "child" nodes and one text node containing "Text Child" with some form of white space in the front (might be a single space). That's what led me to this question.So, does that mean the parser is parsing incorrectly? I'm trying to make sense of the XML spec, but their notation is hard for me to follow, as I've never seen that sort of notation before.
if parser fails to parse it..it will show the error in browser. hope its not showing any. you can write a formated xml file with the mixed content to test and simply open up in browser to be sure.
Link to post
Share on other sites

It's not really a question on whether or not I should do it, but one on what would be parsed into the Text Node.Would everything starting from the ">" of the previous child's ending tag up to the "<" of the next child's tag be put into the text node? From what id looks like, that's what happens with the JavaScript parsing.

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...