Note that these DOM functions expect (and presumably return) all their data in UTF-8 character encoding, regardless of what PHP's current encoding is. This means that text nodes, attribute values etc, should be in utf8.
This applies even if you're generating an XML document which is not ultimately in utf8.
Mark