trichview.support.thirdparty
XML import |
Author |
Message |
Rob |
Posted: 10/20/2004 10:47:40 Hi, I am working on an XML importer, adapted from HTML importer which is nearing completion. I use the NormalizeRichView function (from the HTML importer), but I'd like to make the importer more intelligent so that I do not have to normalize afterwards. Why add something you will delete later, no? The parser I use is the RapWare SAX parser, which spawns events upon finding any element, CDATA, etc. I respond to these by adding text this way: procedure TRvXMLImporter.SAX_StartElement(Sender: TObject; ANamespaceURI, ALocalName, AQName: TRwString; Attributes: IAttributes); var C, I: Integer; S: string; begin if FLastStartElement <> '' then FViewer.AddTextNL('>', FBracketStyleID, -1, -1); FViewer.AddTextNL(GetTabText, rvsDefStyle, 0, -1); FViewer.AddTextNL('<', FBracketStyleID, -1, -1); FLastStartElement := ALocalName.AsString; FViewer.AddTextNL(FLastStartElement, FItemNameStyleID, -1, -1); C := Attributes.Length - 1; for I := 0 to C do begin FViewer.AddTextNL(' ' + Attributes.getLocalName(I), FItemNameStyleID, -1, -1); S := Attributes.getValue(I); if S <> '' then begin FViewer.AddTextNL('="', FBracketStyleID, -1, -1); FViewer.AddTextNL(S, FAttributeValueID, -1, -1); FViewer.AddTextNL('"', FBracketStyleID, -1, -1); end else FViewer.AddTextNL('=""', FBracketStyleID, -1, -1); end; Inc(FTabCount); end; This works, but it seems there is a lot of overhead (when I run the normalizer, it a lot of items) Any idea how I can compress and only add the necessary items? TIA! Rob |
Powered by ABC Amber Outlook Express Converter