0

I have the following XML that came from TNT that I should be able to use to create a shipping label:

https://codebeautify.org/xmlviewer/cb55b98e

I have been supplied with the following XSL file:

https://express.tnt.com/expresswebservices-website/stylesheets/HTMLAddressLabelRenderer.xsl

I have attempted to combine them with the following code:

XmlWriterSettings settings = new XmlWriterSettings
        {
            OmitXmlDeclaration = true,
            ConformanceLevel = ConformanceLevel.Fragment,
            CloseOutput = false,
        };

        // populate the root element with the XML of the address label
        XElement root = new XElement("root", XElement.Parse(await _engine.GetDocument("GET_LABEL", code)));

        XDocument newTree = new XDocument();
        using (XmlWriter writer = XmlWriter.Create(newTree.CreateWriter(), settings))
        {
            XslCompiledTransform xslt = new XslCompiledTransform();
            XsltSettings trev = new XsltSettings
            {
                EnableDocumentFunction = true,
                EnableScript = true
            };
            xslt.Load(@"C:\Users\Trevo\Desktop\HTMLAddressLabelRenderer.xsl", trev, null);

            xslt.Transform(root.CreateReader(), writer);
            writer.Close();
            newTree.Save(@"C:\Users\Trevo\Desktop\result.html");
        }

the HTML only contains the script and head properties and the body is completely empty.

I cannot work out why it isn't working. I have considered that the "root" is not the correct XName but unsure how to work out what it should be.

Any help would be greatly appreciated!

1

1 Answer 1

1
  1. Try this freeformatter
  1. For XML Input, on the first line, enter the below xml, then paste your xml code
<?xml version="1.0"?>
  1. For XML Output, just paste your xsl code.

  2. Click Transform XML. Just play around with the formatter but it will give html output.

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

Comments

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.