Results 1 to 5 of 5
Thread: arborescent xml
- 11-02-2011, 11:40 AM #1
Member
- Join Date
- Aug 2011
- Posts
- 60
- Rep Power
- 0
arborescent xml
I have a xml tree that I want to browse
<?xml version="1.0" encoding="UTF-8"?>
<Ontology name="Ontology">
<DecisionMaker name="SalesManager">
<BusinessProcess name="Order" />
</DecisionMaker>
</Ontology>
but with this code
I can not access to some nodes such "BusinessProcess" in this exampleJava Code:List le=racine.getChildren(); ListIterator le1=le.listIterator(); while(le1.hasNext()) { Element f=(Element) le1.next(); System.out.println("f"+f.getName()); String name=f.getAttributeValue("name"); System.out.println("name"+name); }
and i have as result:
fDecisionMaker
nSalesManager
when i added to my code after "System.out.println("name"+name);"
i have this error "The Content already has an existing parent "DecisionMaker""Java Code:List h=f.getChildren(); ListIterator a1=h.listIterator(); while(a1.hasNext()) { Element e=(Element) a1.next(); le1.add(e); }
i don't know what i do?please help me
- 11-02-2011, 11:53 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,402
- Blog Entries
- 7
- Rep Power
- 17
Re: arborescent xml
That doesn't surprise me: the top level node (Ontology) has one child node (DecisionMaker) which has one child itself (BusinessProcess). Your iterator traverses the children of the top level node only. An Element extends a Node and a Node has a getChildNodes() method; try that on your DecisionMaker node ...
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 11-02-2011, 12:01 PM #3
Member
- Join Date
- Aug 2011
- Posts
- 60
- Rep Power
- 0
Re: arborescent xml
thanks
but i don't have this method "getChildNodes()" when i made
i hade error of unexistion methodJava Code:f.getChildNodes();
- 11-02-2011, 01:32 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,402
- Blog Entries
- 7
- Rep Power
- 17
- 11-02-2011, 01:35 PM #5
Member
- Join Date
- Aug 2011
- Posts
- 60
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks