Load XML Doc (using XML Dom Automation) with a bigtext var.

jwilderjwilder Member Posts: 263
I have a bigtext variable that holds an xml document. I would like to load this into an XML Document using XML DOM automation.

I tried XMLDOC.loadxml(bigtext) but the XMLDOM is expecting a text variable (Bigtext is not consider text).

So I thought I could load the bigtext variable into an instream. This way I could load the XML Doc with:
XMLDOC.load(Instream);

How can I create an instream object from my Bigtext variable?

Comments

  • mandykmandyk Member Posts: 57
    Hi jwilder,

    I am afraid you could not create the instream variable from BigText.
    However, you can create a record variable and use TempBlob as SubType
    TempBlob is virtual table in Navision and very helpful to handle long text or binary data.
    Roughly, the codes should be like following:

    Note: You can set Temporary property as YES for TempBlob variable

    Var readStream as InStream
    Var writeStream as OutStream
    TempBlob.Init;
    TempBlob.Blob.CREATEOUTSTREAM(writeStream);
    BigText.Write(writeStream); //-->store the big text xml to blob field
    TempBlob.Blob.CalcFields(Blob); //--> to refresh up the blob field
    TempBlob.Blob.CREATEINSTREAM(readStream);
    XMLDOM.LOAD(readStream); //--> load your big xml text here

    In short, use tempblob virtual table as mediator.
    Good luck.. :wink:

    Cheers,

    mandyk
  • jwilderjwilder Member Posts: 263
    Exactly what I am looking for. Thanks!
  • jwilderjwilder Member Posts: 263
    I do have one more problem.

    Here's my code (PassXMLString is a Bigtext variable):

    TempBlob.Blob.CREATEOUTSTREAM(StreamOut);
    PassXMLString.WRITE(StreamOut);
    TempBlob.CALCFIELDS(Blob);
    TempBlob.Blob.CREATEINSTREAM(StreamIn);

    CREATE(XMLDoc);
    XMLDoc.load(StreamIn);
    XMLNodeCurr := XMLDoc.documentElement;
    XMLNodeCurr := XMLNodeCurr.selectSingleNode('OrderHeader/CustomerNo');
    EXIT(XMLNodeCurr.text);

    This would be working except that somehow in this process a character was added to the InStream/Blob at the very end. This character makes the XML not valid anymore. If I export the blob and remove the last character the file is valid again.

    Any thoughts?
  • amphysvenaamphysvena Member Posts: 113
    How about this:
    XMLDOC.loadxml(format(bigtext));
Sign In or Register to comment.