PDA

View Full Version : Error inserting XML


TJS
06-07-2006, 10:18 PM
I am trying to add a tool to my app that allows the user to edit raw xml data and save that back to the source file. When the user completes their edits, I want them to be able to click a save button that will do the following:


-- get the text (XML) that was entered/edited
str_NewXML = Input.GetText("inp_Edit");

-- insert that into the previously loaded XML overwriting all contents
XML.InsertXML("*", str_NewXML, XML.REPLACE);

-- save the XML out to the source file
XML.Save(str_XMLDB);

-- display the source file in a web object
Web.LoadURL("web_View", str_XMLDB);


To keep things simple I am loading the XML from the file, pushing it to the input object and simply trying to save... no edits for now until I get this figured out.

Problem is that the XML.Insert() action is failing with an error 37011: An error occurred while trying to insert XML.

Any help is appreciated...

yosik
06-08-2006, 12:01 AM
I may not be right, but I think the problem is that you are defining the element path as "*" in the XML.InsertXML action.

Yossi

TJS
06-08-2006, 06:33 AM
I tried using the literal path but that didn't work either.


XML.InsertXML("root", str_NewXML, XML.REPLACE);

yosik
06-08-2006, 07:25 AM
You need to define the whole path, from "root" to element. Something like:
"database/customer/address_info/country" (I copied the example in the help file).

Yossi

TJ_Tigger
06-08-2006, 07:36 AM
Are you looking to replace the entire XML code or just an element? If you are looking to replace the entire code then I would use XML.SetXML using the string from your Input object as the input for that action. If you are looking to replace just a portion then I would specify the whole path for that portion in the XML.InsertXML.

Tigg

TJS
06-08-2006, 11:08 AM
Yes I am trying to replace the entire <root> element... I'll try the XML.SetXML() instead... Now that I think about it, I guess I could have used TextFile.WriteFromString() as well.

Thanks guys!

TJ_Tigger
06-08-2006, 11:30 AM
If you want some of the builtin XML error checking I would use the XML commands. XML.SetXML will perform some error checking on the contents of the string. If those pass, then I would use the XML.Save to save it to a file.

my .02

Tigg