Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 693245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:44:02+00:00 2026-05-14T02:44:02+00:00

I need to transform a valid XML document to the OFX v1.0.2 format .

  • 0

I need to transform a valid XML document to the OFX v1.0.2 format. This format is more or less XML, but it’s technically invalid and therefore cannot be parsed as XML.

I’m having trouble getting my Xml transformation working because the .Net XslCompiledTransform object insists on interpreting the output as an XML document (which is fair enough).

**Here’s my function to transform the Xml

public string Transform(XmlElement xmlElement, Dictionary<string, object> parameters)
{
    string strReturn = "";

    // Set the settings to allow scripts to executed.
    XsltSettings settings = new XsltSettings(false, true);

    // Load the XSLT Document
    XslCompiledTransform xslt = new XslCompiledTransform();

    xslt.Load(xsltFileName, settings, new XmlUrlResolver());

    // arguments
    XsltArgumentList args = new XsltArgumentList();
    if (parameters != null && parameters.Count > 0)
    {
        foreach (string key in parameters.Keys)
        {
            args.AddParam(key, "", parameters[key]);
        }
    }

    //Create a memory stream to write to
    Stream objStream = new MemoryStream();

    // Transform the xml/xslt into a Writer
    XmlTextWriter xmlWriter = new XmlTextWriter(objStream, Encoding.UTF8);

    // Apply the transform
    xslt.Transform(xmlElement, args, xmlWriter);

    objStream.Seek(0, SeekOrigin.Begin);

    // Read the contents of the stream
    StreamReader objSR = new StreamReader(objStream);

    strReturn = objSR.ReadToEnd();

    return strReturn;
}

If I escape the xml-ish tags using &lt; and &gt, they get removed when I download the file.

Here’s the start of my XSLT:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="text"></xsl:output>
  <xsl:param name="currentdate"></xsl:param>
  <xsl:template match="Transactions">
OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
<OFX>
    <SIGNONMSGSRSV1>
        <SONRS>
            <STATUS>
                <CODE>0
                <SEVERITY>INFO
            </STATUS>
            <DTSERVER><xsl:value-of select="$currentdate" />
            <LANGUAGE>ENG

So can I transform my XML to a plain text string?

UPDATE:

I’ve changed this question. I just realised the obvious answer to the original question. Using the XslCompiledTransform object requires me to write the output to an Xml document using an XmlTextWriter. Obviously it won’t parse. Apologies.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:44:03+00:00Added an answer on May 14, 2026 at 2:44 am

    Xslt can output text; just make sure that you set the output-mode of the xslt to text, and wriet to a TextWriter (there are multiple overloads available). Writing something that is nearly xml in xslt is painful, but possible with disabling the escape rules.

    Here’s an example (albeit ugly) xslt for writing non-xml:

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
    >
        <xsl:output method="text" indent="yes"/>
    
        <xsl:template match="@* | node()">
          <xsl:call-template name="startElement">
            <xsl:with-param name="name" select="'SONRS'"/>
          </xsl:call-template>        
          <xsl:call-template name="startElement">
            <xsl:with-param name="name" select="'STATUS'"/>
            <xsl:with-param name="value" select="0"/>
          </xsl:call-template>
          <xsl:call-template name="startElement">
            <xsl:with-param name="name" select="'SEVERITY'"/>
            <xsl:with-param name="value" select="'INFO'"/>
          </xsl:call-template>
          <xsl:call-template name="endElement">
            <xsl:with-param name="name" select="'SONRS'"/>
          </xsl:call-template>
        </xsl:template>
    
      <xsl:template name="startElement">
        <xsl:param name="name"/>
        <xsl:param name="value"/>
        <xsl:text disable-output-escaping="yes">&lt;</xsl:text>
        <xsl:value-of select="$name"/>
        <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
        <xsl:value-of select="$value"/>
      </xsl:template>
      <xsl:template name="endElement">
        <xsl:param name="name"/>
        <xsl:text disable-output-escaping="yes">&lt;/</xsl:text>
        <xsl:value-of select="$name"/>
        <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
      </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to transform an XML file with XSLT, and this task is kinda
I need to transform my nested sets structure (mysql) into json for this spacetree
I am developing an application were I need to transform XML documents that look
I am having some problems with an XML transform and need some help. The
I need to transform a XML. Usually I would use Saxon and a XSLT
I need to transform some xml into html and pdf formats as part of
I need to transform XML using xslt. Logic: Split the parent if the parent
I have a column with values like this: 01709100011 I need to transform it
I need to transform active record JSON to something like this: { cols: [{id:
I need to transform my XML into another datastructure. I recieve the XML like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.