Skip to content

Commit a96d34f

Browse files
author
Andrew Eiche
committed
More parts of the epub read
1 parent b2e5ba0 commit a96d34f

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

UnityEPubReader/Assets/Scripts/UEPubReader.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ public class UEPubReader {
1010

1111
public string epubFolderLocation { get; private set; }
1212

13-
public Dictionary<string, string> chapters;
13+
private Dictionary<string, string> bookItems;
14+
private List<string> spine;
1415

1516
private string opfFileString;
1617

1718
public UEPubReader(string file){
19+
bookItems = new Dictionary<string, string> ();
20+
spine = new List<string> ();
21+
1822
var fileArray = file.Split('.');
1923

2024
if (fileArray [fileArray.Length - 1].ToLower() != "epub") {
@@ -40,5 +44,24 @@ private void ParseContainer(){
4044
doc.SelectSingleNode("/container/rootfiles/rootfile");
4145
opfFileString = rootFile.Attributes ["full-path"].InnerText;
4246
}
47+
48+
private void ParseOPF(){
49+
var opfFile = epubFolderLocation + "/" + opfFileString;
50+
51+
XmlDocument doc = new XmlDocument ();
52+
doc.Load (opfFile);
53+
54+
var nodes = doc.SelectNodes ("/package/manifest");
55+
56+
foreach (XmlNode node in nodes) {
57+
bookItems[node.Attributes["id"].InnerText] = node.Attributes["href"].InnerText;
58+
}
59+
60+
nodes = doc.SelectNodes("/package/spine");
61+
62+
foreach (XmlNode node in nodes){
63+
spine.Add(node.Attributes["idref"].InnerText);
64+
}
65+
}
4366
}
4467
}

0 commit comments

Comments
 (0)