shadowayex 1 Posted March 14, 2011 Report Share Posted March 14, 2011 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? Quote Link to post Share on other sites
jeffman 86 Posted March 14, 2011 Report Share Posted March 14, 2011 It is not legal. Only white space can exist between nodes. "Text Child" must be wrapped in tags. Quote Link to post Share on other sites
birbal 168 Posted March 14, 2011 Report Share Posted March 14, 2011 (edited) 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 March 14, 2011 by birbal Quote Link to post Share on other sites
shadowayex 1 Posted March 14, 2011 Author Report Share Posted March 14, 2011 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. Quote Link to post Share on other sites
jeffman 86 Posted March 14, 2011 Report Share Posted March 14, 2011 Maybe I'm wrong. I'm not sure why you'd want to do it, though. Quote Link to post Share on other sites
birbal 168 Posted March 14, 2011 Report Share Posted March 14, 2011 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. Quote Link to post Share on other sites
shadowayex 1 Posted March 14, 2011 Author Report Share Posted March 14, 2011 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. Quote Link to post Share on other sites
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.