Jump to content




Recent Status Updates

  • Photo
      18 Aug
    KodeKool

    When faced with a wall of errors and no hope to fix them, remember the following "Programs always do what you tell them to, and seldom what you want them to, but eventually you'll run out of things that can go wrong and it'll just work. and that's the secret to good programming."

    Show comments (2)
View All Updates

Developed by Kemal Taskin
Photo
- - - - -

xml problem help

xml

  • Please log in to reply
15 replies to this topic

#1 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 24 January 2012 - 07:21 AM

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

#2 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 24 January 2012 - 11:18 PM

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
  • 0

#3 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2,560 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java, PHP

Posted 25 January 2012 - 12:57 AM

NoClassDefFound is usually a missing library (jar).
  • 0

#4 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 25 January 2012 - 03:30 AM

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
  • 0

#5 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2,560 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java, PHP

Posted 25 January 2012 - 03:48 AM

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?
  • 0

#6 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 26 January 2012 - 11:54 PM

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.
  • 0

#7 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2,560 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java, PHP

Posted 27 January 2012 - 12:04 AM

Add the attached jar to your project.
(Right click project -> properties -> libraries -> Add jar / folder -> open -> ok)

Attached Files


  • 0

#8 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 27 January 2012 - 01:25 AM

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
  • 0

#9 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2,560 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java, PHP

Posted 27 January 2012 - 01:28 AM

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.
  • 0

#10 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 27 January 2012 - 04:16 AM

I want from xml to json
  • 0

#11 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2,560 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java, PHP

Posted 27 January 2012 - 04:17 AM

Then use one of these:

[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]


  • 0

#12 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 27 January 2012 - 04:45 AM

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.
  • 0





Also tagged with one or more of these keywords: xml