Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Аватара для El Sanchez

Ветеран


Contributor


Сообщения: 1264
Благодарности: 1024

Профиль | Отправить PM | Цитировать


Цитата Iska:
Я и это: [решено] Замена строк в файле формата .xml предлагал, чтобы сделали здесь же на том же самом встроенном Паскале. »
Iska, да легко:
Скрытый текст

Код: Выделить весь код

[Code]
/////////////////////////////////////////////////
procedure VehiclesConfig(const FileName: string);
var
  XMLDoc, XMLNodes, XMLNode: Variant;
  XPath: string;
begin
  try
    XMLDoc := CreateOleObject('Msxml2.DOMDocument');
    XMLDoc.setProperty('SelectionLanguage', 'XPath');
    XMLDoc.async := False;
    XMLDoc.load(FileName);
    if XMLDoc.parseError.errorCode <> 0 then
      RaiseException(string(XMLDoc.parseError.reason));

    XMLNode := XMLDoc.createElement('MediaPath');
    XMLNode.setAttribute('Path', 'Vehicles');

    XPath := '/Config/MediaPath[@Path="Media" and not(following-sibling::*[1][self::MediaPath[@Path="Vehicles"]])]/following-sibling::*[1]';
  #if (Ver < 0x5050600) ; avoid VarIsNull
    XMLNodes := XMLDoc.selectNodes(XPath);
    if XMLNodes.length = 1 then
      XMLDoc.documentElement.insertBefore(XMLNode, XMLNodes.item(0));
  #else
    XMLNodes := XMLDoc.selectSingleNode(XPath);
    if not VarIsClear(XMLNodes) then
      XMLDoc.documentElement.insertBefore(XMLNode, XMLNodes);
  #endif
    XMLDoc.save(FileName);
  except
    ShowExceptionMessage;
  finally
  end;
end;

///////////////////////////
procedure InitializeWizard;
begin
  VehiclesConfig('{#SourcePath}\example.xml');
end;
Это сообщение посчитали полезным следующие участники:

Отправлено: 13:01, 19-05-2018 | #38