shadowayex Posted March 14, 2011 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? Link to comment Share on other sites More sharing options...
jeffman Posted March 14, 2011 Share Posted March 14, 2011 It is not legal. Only white space can exist between nodes. "Text Child" must be wrapped in tags. Link to comment Share on other sites More sharing options...
birbal Posted March 14, 2011 Share Posted March 14, 2011 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? Link to comment Share on other sites More sharing options...
shadowayex Posted March 14, 2011 Author 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. Link to comment Share on other sites More sharing options...
jeffman Posted March 14, 2011 Share Posted March 14, 2011 Maybe I'm wrong. I'm not sure why you'd want to do it, though. Link to comment Share on other sites More sharing options...
birbal Posted March 14, 2011 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. Link to comment Share on other sites More sharing options...
shadowayex Posted March 14, 2011 Author 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.