Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Content Management (Extended ECM)
API, SDK, REST and Web Services
Saving and retrieving XML
ATHANASSIOS_FAMELIARIS
Hello all!I want to be able to create an XML document, manipulate it and then save it to a file on the HD. Then I want to be able to read that file at some point later on. I know that Livelink allows exporting of nodes into XML but I don't want to save a node, I want to save the object which I create. Is there a way to do this? I couldn't do it using export.ExportById( ID, file)Is there a another way, and if so is ther also a way to read that file later on?Finally, is there any documentation for all this? (export and import are not part of the XML package) Thank you!YS
Find more posts tagged with
Comments
Francisco_Alcala-Soler_(iaea_001user3_-_(deleted))
Message from via eLinkHi YS,> I want to be able to create an XML document, manipulate it > and then save it to a file on the HD. Then I want to be able > to read that file at some point later on. > > I know that Livelink allows exporting of nodes into XML but I > don't want to save a node, I want to save the object which I > create. Is there a way to do this? I couldn't do it using > export.ExportById( ID, file)> Is there a another way, and if so is ther also a way to read > that file later on?You have different options depending on what exactly you want to do:a) To create an XML document you can: a.1) Create it as a string: String xmlDoc = '
' + Str.CRLF + \ ' blah blah blah' + Str.CRLF + \ '
' a.2) Create it as a StringWriter object: Object xml = $LLIAPI.XMLStringWriter.New( prgCtx ) xml.WriteXMLDeclaration() Assoc attrs = Assoc.CreateAssoc() attrs.version = "1.0" xml.StartElement( "root-node", attrs ) xml.fIndentLevel = xml.fIndentLevel + 1 xml.SetIndentSpace( xml.fIndentSpace ) Assoc attrs = Assoc.CreateAssoc() attrs.a = "1" xml.WriteElement( "elem", "blah blah blah", attrs ) xml.fIndentLevel = xml.fIndentLevel - 1 xml.SetIndentSpace( xml.fIndentSpace ) xml.EndElement() // root-node String xmlDoc = xml.GetBuffer() Take a look at $LLIAPI.XML; there is plenty of stuff in there. a.3) Create it as a DOM object. DOMParser xmlParser = DOMParser.New() Assoc result = xmlParser.Parse( "path/to/an/XML/file.xml" ) if ( result.ok ) DOMDocument xmlDoc = xmlParser.GetDocument() end Take a look at the XML package in the Oscript doco for more information. If the file you want to parse is a Livelink object, you'll have to dump it to disk before reading it into the parser.b) To manipulate your XML document you can: b.1) Use string parsing for cases a.1) and a.2). b.2) Use the XML package to manipulate your DOMDocument object. What I tend to do here is to apply XSL style sheets to perform the manipulation and transformations.c) To save the file to disk: c.1) For cases a.1) and a.2) simply: Dynamic xmlFile = File.Open( "path/to/XML/file.xml", File.WriteMode ) if ( !IsError( xmlFile ) ) File.Write( xmlFile, xmlDoc ) File.Close( xmlFile ) else echo( "**** " + Error.ErrorToString( xmlFile ) + ": " + "path/to/XML/file.xml" ) end c.2) With the XML package you can dump the result of an XSL transformation to disk and then import it into Livelink with the DAPI or only load it up for further processing.> Finally, is there any documentation for all this? (export and > import are not part of the XML package) Thank you!The XML package has some basic documentation, but no code samples, so you'll have to base your code on examples provided by others... I would recommend that you also take a look at the $LLIAPI.XML object.Maybe others can provide better alternatives. This is what comes to mind for now. I hope it helps. CurroThis email message is intended only for the use of the named recipient.Information contained in this email message and its attachments may beprivileged, confidential and protected from disclosure. If you are not theintended recipient, please do not read, copy, use or disclose thiscommunication to others. Also please notify the sender by replying to thismessage and then delete it from your system.
ATHANASSIOS_FAMELIARIS
I haven''t tried it yet but, I think you have solved my problem entirely! Thanks!YS