Search Results

Search found 2 results on 1 pages for 'txmldocument'.

Page 1/1 | 1 

  • How to make TXMLDocument (with the MSXML Implementation) always include the encoding attribute?

    - by Fabricio Araujo
    I have legacy code (I didn't write it) that always included the encoding attribute, but recompiling it to D2010, TXMLDocument doesn't include the enconding anymore. Because the XML data have accented characters both on tags and data, TXMLDocument.LoadFromFile simply throws EDOMParseErros saying that an invalid character is found on the file. Relevant code: Doc := TXMLDocument.Create(nil); try Doc.Active := True; Doc.Encoding := XMLEncoding; RootNode := Doc.CreateElement('Test', ''); Doc.DocumentElement := RootNode; <snip> //Result := Doc.XMl.Text; Doc.SaveToXML(Result); // Both lines gives the same result On older versions of Delphi, the following line is generated: <?xml version="1.0" encoding="ISO-8859-1"?> On D2010, this is generated: <?xml version="1.0"?> If I change manually the line, all works like always worked in the last years. UPDATE: XMLEncoding is a constant and is defined as follow XMLEncoding = 'ISO-8859-1';

    Read the article

  • Using TXMLDocument to serialize form settings to XML and database.

    - by LukLed
    I have an interface: type IXMLSerializable = interface function SaveToXML : DOMString; function SaveToXMLDocument : IXMLDocument; procedure LoadFromXML(AXML : DOMString); end; It is used to serialize some settings of forms or frames to xml. Simple implementation: SaveToXMLDocument: function TSomething.SaveToXMLDocument: IXMLDocument; begin Result := TXMLDocument.Create(nil); with Result do begin Active := True; with AddChild(Self.Name) do begin AddChild(edSomeTextBox.Name).Attributes['Text'] := edSomeTextBox.Text; end; end; Result := XMLDoc; end; LoadFromXML: procedure TSomething.LoadFromXML(AXML: DOMString); var XMLDoc : IXMLDocument; I : Integer; begin XMLDoc := TXMLDocument.Create(nil); with XMLDoc do begin LoadFromXML(AXML); Active := True; with ChildNodes[0] do begin for I := 0 to ChildNodes.Count-1 do begin If ChildNodes[I].NodeName = 'edSomeTextBox' then edSomeTextBox.Text := ChildNodes[I].Attributes['Text']; end; end; end; end; SaveToXML: function TSomething.SaveToXML: DOMString; begin SaveToXMLDocument.SaveToXML(Result); end; DOMString result of SaveToXML is saved to database to blob field. I had some encoding issues with other implementations and this one works fine (right now). Do you see any dangers in this code? Can I have issues with different settings on various machines and systems?

    Read the article

1