-1

just had some problem with libXML printing this XML code in a formatted way:

<?xml version="1.0" encoding="UTF-8"?> 
<parent>anyvalue
  <child>anyvalue</child>
</parent>

LibXML puts the whole <parent> element in one line like this:

<parent>anyvalue<child>anyvalue</child></parent>

not very nice.

My question is, if that is valid XML.

No Errors in any webbased validators so far. Used w3c validator and some more.

In case this is valid XML, is there any solution to prevent indentation for this type of xml structure in libXML?

Thanks!

Jonas93
  • 21
  • 3

1 Answers1

0

It looks like all of your questions are answered before. see: Can a XML element contain text and child elements at the same time?

Personally I would create an attribute containing the value you wanted to add to the parent. like this:

<parent name:"parentvalue">
    <child>anyvalue</child>
</parent>

seems more logical to me, and more readable to.

And for your other question, I think someone already answered this one. see: xml indentation

Community
  • 1
  • 1
SuperRetro
  • 91
  • 6