It might be helpful if you provided simple sample input
and output. I honestly don't follow what it is you want to do; especially confusing (to me at least) is why the lookup and id attributes (for KEYs elements) and the name and id attributes (for Area elements) have the same values.
In your code, where is the getSingleElementbyXPath() method defined?
On 11/27/06, Power_PC@gmx.net <
Power_PC@gmx.net> wrote:Hi,
my problem is to resolve references to other xml-tags. Here is my xml file:
<Project>
<KEYs name="host" id="23" lookup="/Project/Area/[@name=''YES']" id="/ Project/Area/[@name=''YES']" />
<KEYs name="server" id="404" lookup="/Project/Area/[@name=''XOR']" id="/Project/Area/[@name=''XOR']" />
...
<Area name="YES" id='"YES"'/>
<Area name="XOR" id='"XOR"'/>
...
</Project>
i want to resolve the references - after importing the file i want to show:
...lookup= and here should be the value of the references - a pointer should go to Project--Area--name--yes, this mean in the tag area where name is yes and id is yes, so finally the xml file should have the resolved value. i have tried with xpath and saxbuilder, but it doesnt work: here my codesample:
...
public static void main(String[] args) {
SAXBuilder builder = new SAXBuilder();
try {
xmlfile =
builder.build( new File("sample/xdstrainig.xml"));
getRoot = xmlfile.getRootElement();
allvalue = getSingleElementbyXPath("/Project/KEYs[@name='host']");
List mylist = getRoot.getChildren("KEYs");
Iterator iter = mylist.iterator();
Element e;
while(iter.hasNext() {
e = (Element) iter.next();
String stringName = e.getName();
Element e2 = (Element) XPath.selectSingleNode(getRoot, "/Project/KEYs/" +stringName);
...
but how to resolve the references? I think with getSingleElementbyXPath(), but how can i do this??
THX for any suggestions!!!!!!
Kind regards,
Jack
--
"Ein Herz für Kinder" - Ihre Spende hilft! Aktion:
www.deutschlandsegelt.de
Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht!
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com