AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Probleme mit TJvSimpleXML

Ein Thema von SlpLow · begonnen am 19. Jan 2014
Antwort Antwort
SlpLow

Registriert seit: 4. Nov 2013
28 Beiträge
 
#1

Probleme mit TJvSimpleXML

  Alt 19. Jan 2014, 20:27
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

Geändert von SlpLow (20. Jan 2014 um 07:08 Uhr)
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:37 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