Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Java und XML DocType

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

Ich habe eine Ursprungs-XML die ich mit Java in ein Document (mDoc) parse, das Problem ist aber, das der DocType der alten XML-Datei nach dem Bearbeiten nicht mit in die Neue geschrieben wird. Unten habe ich zwei Beispiele, eins wie es ausgegeben wird und eins wie es sein soll und auch in der alten XML-Datei ist.

So soll es sein:


<?xml version="1.0" ?>

<!DOCTYPE connections (View Source for full doctype...)>

<connections>

   <connection>

      <ConnectionType>JDBC</ConnectionType>

      ...

   </connection>

</connections>

Und wird es ausgegeben:

<?xml version="1.0" encoding="UTF-8" ?>

<connections>

   <connection>

      <ConnectionType>JDBC</ConnectionType>

      ...

   </connection>

</connections>

Hier ein Auszug vom Code

public void editXmlFile() {

   try{

      File xmlFile = new File(mPath);

      if(!xmlFile.exists()){

         System.out.println("The given File does not exist.");

      }else if(mPath == null || mPath.equals("")){

         System.out.println("First you have to set the path of the XML-File.");

      }else {

         DOMParser parser = new DOMParser();

         parser.parse(xmlFile.getAbsolutePath());

         mDoc = parser.getDocument();


         // Hier wird mit mDoc gearbeitet


         Transformer transformer = TransformerFactory.newInstance().newTransformer();

         transformer.setOutputProperty(OutputKeys.METHOD,"xml");


         DOMSource source = new DOMSource(mDoc);

         StreamResult result = new StreamResult(xmlFile);

         transformer.transform(source, result);

      }

   }catch(Exception ex){

   }

}

Wäre nett, wenn mir jemand einen Vorschlag machen könnte. Thx.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.