Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2004, 04:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Looks like the problem is in the client-side code, the image data is not being sent:
Code:
function CreateXml()
{
...
    senv+="<imgdata></imgdata>\n";
...
 
Old September 24th, 2004, 05:37 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Quote:
quote:Originally posted by pgtips
 Looks like the problem is in the client-side code, the image data is not being sent:
Code:
function CreateXml()
{
...
    senv+="<imgdata></imgdata>\n";
...
This part is supposed to add the image data.
Code:
var oDoc=new ActiveXObject("Microsoft.XMLDOM");
            oDoc.loadXML(senv);
            var oNode=oDoc.selectSingleNode("//imgdata");
            oNode.dataType="bin.base64";
            oNode.nodeTypedValue=ostream.Read();
            Textarea1.value=oDoc.xml;

            xmlhttp.Send(senv);
            ostream.Close();
Trying to establish if the Textarea1 shows the binary data...
It won't work on a decent parser because the imagedata node is not selected properly, it's in a namespace. But in that case the code should error. It's such a messay post it's hard to know what's happening :)

--

Joe (Co-author Beginning XML, 3rd edition)
 
Old September 28th, 2004, 05:02 PM
Registered User
 
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks, I found my problem: I was send "senv" instead of "xmldoc.xml"

Quote:
quote:Originally posted by joefawcett
 
Quote:
quote:Originally posted by pgtips
Quote:
 Looks like the problem is in the client-side code, the image data is not being sent:
Code:
function CreateXml()
{
...
    senv+="<imgdata></imgdata>\n";
...
This part is supposed to add the image data.
Code:
var oDoc=new ActiveXObject("Microsoft.XMLDOM");
            oDoc.loadXML(senv);
            var oNode=oDoc.selectSingleNode("//imgdata");
            oNode.dataType="bin.base64";
            oNode.nodeTypedValue=ostream.Read();
            Textarea1.value=oDoc.xml;

            xmlhttp.Send(senv);
            ostream.Close();
Trying to establish if the Textarea1 shows the binary data...
It won't work on a decent parser because the imagedata node is not selected properly, it's in a namespace. But in that case the code should error. It's such a messay post it's hard to know what's happening :)

--

Joe (Co-author Beginning XML, 3rd edition)
 
Old August 3rd, 2006, 04:02 PM
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi mookashi
I am facing the same problem with .NET here and the situation is same as yours.
Can you please tell me how you did solve the issue?
If possible can you post /or send me the snippet which takes care of reading the binarydata from XML and saving as tiff file
My code goes like this and i am not able to assign the datatype
        Dim node As MSXML2.IXMLDOMNode
        Dim odoc As New MSXML2.DOMDocument50
        Dim inputXML As String = "C:\SUPPORT\testcode\VBXML\Input\PublishDocImagesJ msReq.xml"
        Try


            odoc.load(inputXML)
            odoc.async = False
            Dim oStream As New ADODB.Stream
            oStream.Type = 1 '//Binary
            oStream.Open()
            node = odoc.documentElement.selectSingleNode("//ContentInByteArray")
            node.dataType = "bin.base64"
            oStream.Write(node.nodeTypedValue)
            oStream.SaveToFile(PUBLISH_REQUEST_DECODED_TIFFFIL E)
            oStream.Close()
        Catch ex As System.Exception
            System.Console.WriteLine("{0}", ex.Message)

Appreciate your early response

Quote:
quote:Originally posted by mookashi
 hi,
im a new member to this forum. i am having a problem displaying the image passed over through an XML document.

my VB application receives an xml document in which one of the elements has base64encoded data of tiff image. Now i want to read this data and save the image in the local disk. i understand that we have to decode the data and then write into the disk in binary mode and all that. i have tried many options but nothing works. whenever i try to open the image that i have saved it says invalid data format. here's what im trying to do:

     Dim objFile as scripting.FileSystemObject
     Dim objImageFile as scripting.TextStream
     Dim btArr() as Byte

        strBody = oNode.Text
' This node contains the base64 encoded data
' I have even tried strBody=oNode.nodeTypedValue


        strBody = Replace(strBody, "\r\n", "")
        strBody = Replace(strBody, " ", "")
        strBody = Replace(strBody, vbCrLf, "")
        strBody = Replace(strBody, vbTab, "")

        strBody = CStr(Base64decode(strBody))
        btArr = strBody
' can i directly assign a string to a byte array as done above

     Set objImageFile = objFile.CreateTextFile("C:\test.tif", True)
     objImageFile.Write (btArr)
     objImageFile.Close

where im i going wrong?????
 
Old August 3rd, 2006, 05:52 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Can you show the structure of the XML? You must also set the async property before loading the doc. The load method returns true or false. If false your file is malformed. The element holding the data should already be of type base64, there's no need to set it. One final thing is that version 5.0 may not support xdr schemas. Try with version 4.0. Why not use .net XML rather than COM?

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Encode image to base64? OniShirox Javascript How-To 4 July 5th, 2007 03:10 AM
Image Editing and Saving aliirfan84 ASP.NET 2.0 Professional 2 May 28th, 2007 12:12 AM
Base64-encoded files harpua Classic ASP Professional 2 June 19th, 2006 12:04 PM
PNG image in base64 encoding janise PHP How-To 4 April 20th, 2006 02:30 PM
Image Upload to base64 format laker66 ASP.NET 1.0 and 1.1 Basics 1 April 8th, 2004 12:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.