• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is there java class to parse xml nodes?

 
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
-initial response edited out-

lets just kill this thread, it has gone far off topic and isnt really much use anymore
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic