Convert XML file data to byte array by FromBase64String passing(string xmlData)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BobbyS
    New Member
    • Jan 2008
    • 1

    Convert XML file data to byte array by FromBase64String passing(string xmlData)

    I've a xml file.I'm taking its data passing it to a method in string form and converting that string "xmlData" to a array of bytes by Convert.FromBas e64String(xmlDa ta) but I'm getting a exception "Invalid character in Base-64 string."

    My code is like this.

    XmlTextReader xmlReader = new XmlTextReader(X ML_LAYOUT_FILE_ PATH);
    XmlDocument doc = new XmlDocument();
    doc.Load(xmlRea der);
    StringWriter writer = new StringWriter();
    XmlTextWriter xmlWriter = new XmlTextWriter(w riter);
    doc.WriteTo(xml Writer);

    string xmlData = writer.ToString ();

    byte[] userSettings = Convert.FromBas e64String(xmlDa ta);---------Exception is thrown here.

    Here XML_LAYOUT_FILE _PATH is the xml file location.

    So anybody can suggest some solution as to why this exception is coming and what is the solution to it.

    My xml file is like this.

    <SOAP-ENV:Envelope xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http ://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap .org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap .org/soap/envelope/" xmlns:clr="http ://schemas.microso ft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingSty le="http://schemas.xmlsoap .org/soap/encoding/">
    <SOAP-ENV:Body>
    ------------------------
    ------------------------
    Content of file
    -----------------------
    ----------------------
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>


    Does this <SOAP-ENV--------> tag is the problem?
Working...