Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Probleme mit TJvSimpleXML (https://www.delphipraxis.net/178654-probleme-mit-tjvsimplexml.html)

SlpLow 19. Jan 2014 20:27

Probleme mit TJvSimpleXML
 
I ask the help by JclSimpleXml

Have such a the file
<?xml version="1.0" encoding="windows-1251" standalone="no"?>
<library>
<section name="textbooks">
<IDX description="author1" appkey="book"/>
</section>
<section name="handbooks">
<IDX description="author1" appkey="book"/>
<IDX description="author2" appkey="book"/>
<IDX description="author3" appkey="book"/>
</section>
</library>

Necessary add and delete "Section" and "IDX" elements

My attempt to add elements
Delphi-Quellcode:
procedure TForm1.SaveClick(Sender: TObject);
const
  MyXML = 'C:\MyFile\Book.xml';
var
  XML: TJclSimpleXML;
  Root: TJclSimpleXMLElem;
  I: Integer;
  Section, DecStr: string;
  Str: TStringList;
begin
  DecStr := combobox1.Text; // Section selected of combobox
  if FileExists(MyXML) then
  begin
    XML := TJclSimpleXML.Create;
    Str := TStringList.Create;
    try
      XML.LoadFromFile(MyXML);
      XML.Root.Name := 'library';
      Root := XML.Root;
      for I := 0 to XML.Root.ItemCount - 1 do
      begin
        Section := Root.Items.Item[I].Properties.Value('name');
        if SameText(Section, DecStr) = True then
        begin
          begin
            with XML.Root.Items.Item[I].Items.Insert('IDX', combobox1.ItemIndex) do
            begin
              Properties.Add('author', edit1.Text);
              Properties.Add('book', EntityEncode(edit2.Text));
            end;
          end;
        end;
      end;
      DecStr := XMLDecode(XML.SaveToString);
      Str.Add(DecStr);
      Str.SaveToFile(MyXML , TEncoding.Default);
    finally
      XML.Free;
      FreeAndNil(Str);
    end;
  end;
end;
I can not insert them to end of Section

How to implement the insertion and removal "Section" and "IDX"

vereinbart aber Probleme bei der Decodierung EntityEncode


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:25 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz