Search code examples
xmllinq-to-xmlxelement

XDocument: Create custom declaration


I want to create Windows Media Player playlist files with XDocument. Therefore I have to create this declaration:

<?wpl version="1.0"?>

However, the XDeclaration object doesn't allow to replace "xml" with "wpl". Is there a proper way to handle this?


Solution

  • That's a processing instruction, not an XML declaration.

    new XProcessingInstruction("wpl", "version=\"1.0\"")
    

    Your document is still an XML document, so you can additionally include <?xml version="1.0"?> at the top, but that's optional.