Skip to content

Instantly share code, notes, and snippets.

@Rafael09ED
Last active February 15, 2017 18:39
Show Gist options
  • Save Rafael09ED/73cb6ef13fa8a79978e0a1e3ef9792c4 to your computer and use it in GitHub Desktop.
Save Rafael09ED/73cb6ef13fa8a79978e0a1e3ef9792c4 to your computer and use it in GitHub Desktop.
/**
* FalloutNMMModListParser.java
* Purpose: Generates List of mods w/ links do downloads from a profile modlist.xml file
* specifically formatted for reddit
*
* @author Rafael09ED
* @version 1.0 2/15/2017
*/
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.util.Scanner;
public class FalloutNMMModListParser {
public static void main(String[] args) {
try {
System.out.println("Enter file path of the modlist");
Scanner sc = new Scanner(System.in);
File inputFile = new File(sc.nextLine());
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputFile);
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName("modInfo");
int temp = 0;
for (; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String string = "["
+ eElement.getAttribute("modName").trim() + "]" +
"(http://www.nexusmods.com/fallout4/mods/" + eElement.getAttribute("modId") + ")"
+ "\n";
System.out.println(string);
}
}
System.out.println(temp + " mods listed");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment