Jump to content

xml problem help

- - - - -

  • Please log in to reply
15 replies to this topic

#1
Mozana

Mozana

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
XMLSerializer xmlSerializer = new XMLSerializer();
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException

#2
Mozana

Mozana

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
Guys please help me solve this problem, I'm trying to create an xml doc and later make it a json object, any suggestions any one

#3
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
NoClassDefFound is usually a missing library (jar).

#4
Mozana

Mozana

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
lol, thank you, let me check that out

---------- Post added at 11:30 AM ---------- Previous post was at 10:33 AM ----------

Nah, i don't know but i can't find that class, can I not instantiate XMLSerialzer the way I tryd?
Then will you please tell me how

#5
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
That class probably comes out of the commons-lang-2.x.jar (apache)
- Where's that XmlSerializer from?
- Is that a web project, or normal java application?
- Does it use maven?
- What IDE do you use?

#6
Mozana

Mozana

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
maven ? I dont no what dat is, its a web appl;
The habitat of the serializer "is import net.sf.json.xml.XMLSerializer";
I am using netbeans 7
Sorry for taking so long, n tnx.

#7
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Add the attached jar to your project.
(Right click project -> properties -> libraries -> Add jar / folder -> open -> ok)

Attached Files



#8
Mozana

Mozana

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
thank you i m gonna try it nw

---------- Post added at 09:25 AM ---------- Previous post was at 09:12 AM ----------

so i added it, but i how do i reference the xml

#9
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
1) Do you want to do XML to JSon, or JSon to xml?
2) Do you have the XML in a file or a String?
3) Look at the method summary of XMLSerializer (Overview (json-lib jdk 5 API)) The api isn't that hard. It's very clear which method to pick for each case.

#10
Mozana

Mozana

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
I want from xml to json

#11
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Then use one of these:

Quote

[TABLE="width: 100%"]
[TR="class: TableRowColor, bgcolor: white"]
[TD="width: 1%, align: right"] JSON[/TD]
[TD]readFromFile(File file)
Creates a JSON value from a File.[/TD]
[/TR]
[TR="class: TableRowColor, bgcolor: white"]
[TD="width: 1%, align: right"] JSON[/TD]
[TD]readFromFile(String path)
Creates a JSON value from a File.[/TD]
[/TR]
[TR="class: TableRowColor, bgcolor: white"]
[TD="width: 1%, align: right"] JSON[/TD]
[TD]readFromStream(InputStream stream)
Creates a JSON value from an input stream.[/TD]
[/TR]
[/TABLE]


#12
Mozana

Mozana

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
I first tryd using a string, bt dat seems rather tricky. so i created a file nw i wana create the json from an xml doc;

JSONObject json = JSONObject.fromObject("{\"name\":\"json\",\"bool\":true,\"int\":1}");
i dnt no wat dat is.

---------- Post added at 12:45 PM ---------- Previous post was at 12:31 PM ----------

XMLSerializer xmlSerializer = new XMLSerializer();

        JSONObject json = (JSONObject) xmlSerializer.read(xmlResult);
The first line is the one that's got error, the thing is i dnt get hw duz dat line throw exception.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users