1

I am trying to create a page with .xml extension. Below are the steps I followed:

  • Created a schema with one text field.
  • Created a component with above schema and added desired xml content to component field.
  • Created a DWT and CT for component.
  • Created a page DWT to render component presentations.
  • Created a PT with extension as ".xml".
  • Created a page with above PT and added the above component.

Tried to publish the page.Publish is successful but when i try to view the page, i get an error as below.While page preview works fine.

enter image description here

  • Have you tried to see what is really publishing in the final page published? Sounds like strange characters inside the xml file. – Raúl Escudero Jan 28 '16 at 8:37
  • The page that got published contains the xml int below format <?xml version="1.0" encoding="UTF-8" standalone="no" ?> – user1810 Jan 28 '16 at 9:00
  • I guess you are replying to a comment. If so, could you please move it comments OR update the question adding it. – Saurabh Gangwar Jan 28 '16 at 14:38
  • I moved your answer and its comments to a comment in your original question. Stack Exchange sites are different from typical forums. We have one question to start a post and multiple answers for that questions. Follow up info should be added to your original question or in comments. – Alvin Reyes Jan 29 '16 at 8:02
2

As the component content is inside an xml itself, the text is going to be "escaped", so you need something to unescape the content. So the xml is going to be published full of "& lt;" and "& gt;" characters.

What we usually use is a C# Fragment to unscape such characters. Something like this:

Item salida = package.GetByName(Package.OutputName);

string strSalida = salida.GetAsString();
strSalida = strSalida.Replace("&lt;","<");
strSalida = strSalida.Replace("&gt;",">");

package.Remove(salida);
salida.SetAsString(strSalida);
package.PushItem("Output", salida);

And Add this C# Fragment after the Dreamweaver Template in the Page Template, as the last stage of the publishing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.