diff src/goodjava/xml/XmlElement.java @ 1791:f8f5c51f5b36

xml work
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 26 Dec 2023 19:16:18 -0700
parents a8c685a894b4
children a55a891a4f67
line wrap: on
line diff
--- a/src/goodjava/xml/XmlElement.java	Mon Dec 25 23:07:59 2023 -0700
+++ b/src/goodjava/xml/XmlElement.java	Tue Dec 26 19:16:18 2023 -0700
@@ -7,6 +7,7 @@
 	public final String name;
 	public final Map<String,String> attributes;
 	private Object content = null;
+	private XmlElement parent = null;
 
 	public XmlElement(String name,Map<String,String> attributes) {
 		this.name = name;
@@ -14,6 +15,10 @@
 		this.content = null;
 	}
 
+	public XmlElement getParent() {
+		return parent;
+	}
+
 	public Object getContent() {
 		return content;
 	}
@@ -34,6 +39,9 @@
 		if( content.length == 0 )
 			throw new IllegalArgumentException("content can't be empty");
 		this.content = content;
+		for( XmlElement el : content ) {
+			el.parent = this;
+		}
 	}
 
 	@Override public String toString() {