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

jwilder
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?
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?
Jason Wilder
jwilder@stonewallkitchen.com
jwilder@stonewallkitchen.com
0
Comments
-
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..
Cheers,
mandyk0 -
-
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?Jason Wilder
jwilder@stonewallkitchen.com0 -
How about this:
XMLDOC.loadxml(format(bigtext));0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions