Jump to content

Sibling text nodes and white space


shadowayex
 Share

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 comment
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 comment
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 comment
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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...