0

Is SomeText ok in XML node, if there are Childnodes? Is the below code valid?

<main att="123">SomeText
    <child>sample</child>
</main>
RJS
  • 13
  • 3

2 Answers2

4

Whether your example is a valid XML document depends on the Document Type Definition you wish to validate it against. It is well-formed, tough. That is, nothing in the XML specification forbids you to write such documents.

5gon12eder
  • 24,280
  • 5
  • 45
  • 92
  • The xml is valid, but json_encode() fails on this. I did a rewrite of the php function [here](http://stackoverflow.com/questions/27633518/how-to-get-json-from-xml-string) – RJS Dec 26 '14 at 06:18
0

Is it possible to have text and child elements, see: http://www.w3schools.com/schema/schema_complex_mixed.asp

It depends on the xsd that you are validating against.

alampada
  • 2,329
  • 1
  • 23
  • 18