1

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

How do I add this object to the XDocument?
I think my code sample should give you enough to go on. Adding a processing instruction works like adding any other type of node. You'll figure it out.
But the wpl file format as generated by Windows Media Player only has the <wpl /> instruction. Can this be done somehow?
As I was trying to say. The XML declaration is optional. You can have it or omit it, that won't change very much. The XML declaration is for configuring the XML parser, it sets the version (1.0 or 1.1) and encoding of the file. A processing instruction is for configuring the application that sits behind the parser. You can have both and nothing will break. See stackoverflow.com/a/4679212/18771

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.