Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions OmniXMLPersistent.pas
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,6 @@ class procedure TOmniXMLReader.LoadFromFile(Collection: TCollection; FileName: s

constructor TOmniXMLReader.Create(const PropFormat: TPropsFormat = pfAuto);
begin
if PropFormat = pfAuto then
raise EOmniXMLPersistent.Create('Auto PropFormat not allowed here.');

PropsFormat := PropFormat;
end;

Expand All @@ -509,25 +506,32 @@ function TOmniXMLReader.FindElement(const Root: IXMLElement; const TagName: XmlS
end;

function TOmniXMLReader.InternalReadText(Root: IXMLElement; Name: XmlString; var Value: XmlString): Boolean;
var
PropNode: IXMLElement;
AttrNode: IXMLNode;

function ReadNodes: Boolean;
var
PropNode: IXMLElement;
begin
PropNode := FindElement(Root, Name);
Result := PropNode <> nil;
if Result then
Value := PropNode.Text;
end;

function ReadAttributes: Boolean;
var
AttrNode: IXMLNode;
begin
AttrNode := Root.Attributes.GetNamedItem(Name);
Result := AttrNode <> nil;
if Result then
Value := AttrNode.NodeValue;
end;

begin
case PropsFormat of
pfAttributes:
begin
AttrNode := Root.Attributes.GetNamedItem(Name);
Result := AttrNode <> nil;
if Result then
Value := AttrNode.NodeValue;
end;
pfNodes:
begin
PropNode := FindElement(Root, Name);
Result := PropNode <> nil;
if Result then
Value := PropNode.Text;
end;
pfAttributes: Result := ReadAttributes();
pfNodes: Result := ReadNodes();
pfAuto: Result := (ReadNodes() or ReadAttributes)
else
Result := False;
end;
Expand Down