File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Is there java class to parse xml nodes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Is there java class to parse xml nodes?" Watch "Is there java class to parse xml nodes?" New topic
Author

Is there java class to parse xml nodes?

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

I have been able to find java that will go through a .properties file or go through nodes, and then I can use those to populate a tree.

But is there a class I can look into that will do the same type of thing for xml data?


True wisdom is in knowing you know nothing - Socrates
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Well, yeah, the classes in the javax.xml.parsers package for a start. But you'll need more than the API documentation for you to be able to use them. Right now you're flailing around and firing random questions at the forum because you don't know the basics. I would suggest you read some tutorials. Like for example this one:

Java API for XML Processing

There's also ERH's book Processing XML with Java which is online. It's several years old but XML hasn't changed since then so it isn't all that dated.


Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Ha believe me, I have been reading tutorials... more than you would believe
Ill try this one though, thanks

I mean I basically know what needs to happen here, and I dont think I even need this class I posted this thread about, because Im already using simplexml to deserialize my xml. It is the java that happens afterwards that is giving me trouble.

I need to follow something like:

XML -> simple XML -> java objects -> tree model

and here is my method to read the xml:



So the data has been converted right? Now I just need to go through that data and pick out certain pieces. It might help if someone could tell me what the data looks like after it is put through the method above.

I will try this tutorial as well though,

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

You want to know what that code does? Then you're going to have to ask the person who wrote it. It uses a lot of classes which aren't in the standard API. And whatever it does, it doesn't look suitable to me. Just from the names of the classes. I don't see why a "Device" class would be useful for building a tree structure.

I think I have said this before, but I think you should desist from your idea that you can grab some random code off the internet and somehow make it do what you want. So far all that has got you is a bunch of random code which you don't understand.
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

would you mind telling me what to call xyz in the following: <tag attribute=y>xyz</tag>
I know what to call the tag and attribute, but I dont know what the correct word is to refer to xyz

In fact, here are a few more examples of my code, to give you a better idea of my level of knowledge with this stuff






Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Well, I apologize too. From the questions you were asking, it very much looked like you didn't have a clue about XML. But perhaps the problem is... well, I don't know. Here's a question that you asked:
It might help if someone could tell me what the data looks like after it is put through the method above.

Well, it's a Device object. It isn't XML any more because you parsed it into a Java object. So asking "what the data looks like" is... how can I put it... it's a peculiar question. What you have is a Device object.

And here's another question you asked:
Now I just need to go through that data and pick out certain pieces.

Well, it's a Device object. It's got for example a getName() method. So if you want to pick out the name, you call its getName() method. This isn't an XML question at all. It's just Java. So I'm confused. On the one hand you've written some code which does XML-to-object binding, which is quite sophisticated, but on the other hand you appear not to know what that code produces. Perhaps that's what led me to believe that you were just copying and pasting other people's code.

Anyway, again I didn't mean to be rude. My answers were based solely on what I saw in your posts, and I was confused.

But obviously you're confused too, that's why you're asking here. And now I've lost track of what your question was.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Matt Kohanek wrote:If you are still so inclined, would you mind telling me what to call xyz in the following: <tag attribute=y>xyz</tag>
I know what to call the tag and attribute, but I dont know what the correct word is to refer to xyz


Here's a straightforward question I can answer: that's a text node.
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Ha, I very much am clueless about xml honestly. And it took me about...all of April to come up with the code I have there. So I am expecting something similar for the problems I am having now, but the thing is I need to have this tree working by mid June, which is why I am looking at tons of different example code and asking so many questions.

Thanks for the response to my previous question, you and I both wish my questions were all that simple lol
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

And I will continue to move any questions with an XML dimension here. I'm still not sure why you insist that questions on parsing XML do not belong in an XML forum.

And basic Java questions like Paul has pointed out have no business in the advanced forum in any case.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

-initial response edited out-

lets just kill this thread, it has gone far off topic and isnt really much use anymore
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

There is no disagreement. Paul has simply pointed out that in your XML-oriented post there are some basic Java questions.

Any in-depth post will have multiple dimensions. A post titled "Is there java class to parse xml nodes?" has a clear central focus on XML.

Any further discussion should be taken to email or PM.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

Also... when the topic of a post has morphed to the point where it is no longer focuses on the original topic, it's sometimes a sign that a new topic should be spawned.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there java class to parse xml nodes?