Re: JDOM and &qout;

From: mali_djuro (mali_djuro_REMOVE_at_net.hr)
Date: 02/03/04


Date: Tue, 3 Feb 2004 09:21:30 +0100


"Raymond DeCampo" <rdecampo@spam-I-am-not.twcny.rr.com> wrote in message
news:tICTb.28348$n62.22674@twister.nyroc.rr.com...
> mali_djuro wrote:
> > Hi,
> > i didn't understand you.
> > i need to create document object and than transform it to string, or
file.
> >
> > if you have some examples please write to me.
> >
> > thanks.
> >
> > "Raymond DeCampo" <rdecampo@spam-I-am-not.twcny.rr.com> wrote in message
> > news:AGWSb.15452$%72.3792@twister.nyroc.rr.com...
> >
> >>mali_djuro wrote:
> >>
> >>>Hi all,
> >>>i used JDOM to create XML file.
> >>>first, i get data from database and create Document object. in some
data
> >
> > i
> >
> >>>have quotas, so it makes replacment in content of elements. for
example:
> >>>if i have "Hi" in database, i will have &quot;Hi&quot; in content of
> >>>element. And it is ok, because in xml does not exist ", at least i
think
> >>>that.
> >>>After it i want to make convert from document to string. I used
> >>>
> >>>XMLOutputter serializer = new XMLOutputter();
> >>>String output = serializer.outputString(document);
> >>>
> >>>now, when i look what's happened with &quot;Hi&quot; i found following
> >>>string
> >>>&amp;quot;Hi&amp;quot;
> >>>it makes conversion of & again, and that is not ok.
> >>>
> >>>has someone similiar problem? or do you know how to solve it?
> >>>
> >>>i can make parsing of string again and cut what is wrong, but is it
> >
> > possible
> >
> >>>to set something without that?
> >>>
> >>
> >>Friend,
> >>
> >>It is likely that the good people at JDOM have already considered your
> >>problem and are accounting for it themselves. So, it is probably safe
> >>to simply pass "Hi" directly to the JDOM API without prior escaping.
> >>
> >>Ray
> >>
> >
>
> Please do not top post, especially in reply to someone who has bottom
> posted.
>
> If you wish more specific advise, you will have to supply more specific
> code yourself. For example, what is document in your code above?
> Ideally, you should post the smallest possible complete program that
> exhibits the issue you are having. Provide the expected and actual
> outputs. I suspect you will be most pleased from the response of the
group.
>
> Ray
>

sorry, ray.
i didn't think when i answered on your post.
i am back on my problem:

function transformXMLToString(){

//here, i got some object
SomeObject so = new SomeObject();
so.setName("mali");
so.setHi("\"Hi\""); // here i have value of so.hi = "Hi" with qoutas

//now i make Document object

Element root = new Element("mainNode");
String output = new String();
Document document = new Document(root);
try{
     //NodeName
     Element sub = new Element("nodeName");
     sub.addContent(so.getName());
     root.addContent(prom);

     //NodeHi
     sub = new Element("NodeHi");
     sub.addContent(so.getHi()); //content of sub is &quot;Hi&quot;
     root.addContent(prom);

     XMLOutputter serializer = new XMLOutputter();
     output = serializer.outputString(document);

  }
    catch(Exception e){
     System.out.println(e.getMessage());
 }
  return output;
}

so, for output i get
    <?xml version="1.0"?>
    <nodeMain>
      <NodeName>mali</NodeName>
      <NodeHi>&amp;quot;Hi&amp;quot;</NodeHi>
    </nodeMain>

but i want for output following string
    <?xml version="1.0"?>
    <nodeMain>
      <NodeName>mali</NodeName>
      <NodeHi>&quot;Hi&quot;</NodeHi>
    </nodeMain>

thanks



Relevant Pages

  • Re: Save User Information
    ... Function SetCustomProperty(strPropName As String, intPropType _ ... Dim doc As Document, prp As Property ... Set cnt = dbs.Containers!Databases ' Define Container object. ... Set doc = cnt.Documents!UserDefined ' Define Document object. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Save User Information
    ... >Function SetCustomProperty(strPropName As String, intPropType _ ... > Set cnt = dbs.Containers!Databases ' Define Container object. ... >' to Properties collection of Document object. ... > Dim doc As Document, ...
    (microsoft.public.access.modulesdaovba)
  • Access doc from web
    ... the first thing I tried was putting in the entire URL as a string ... doesn't seem to like the 'http://' reference. ... I also tried referencing the document object that I already opened. ... 'doc1.FullName', it still throws the same error saying, "The document name or ...
    (microsoft.public.scripting.vbscript)
  • Re: JDOM and &qout;
    ... > i need to create document object and than transform it to string, ... exhibits the issue you are having. ...
    (comp.lang.java)
  • JDOM and &qout;
    ... i used JDOM to create XML file. ... i get data from database and create Document object. ... After it i want to make convert from document to string. ... XMLOutputter serializer = new XMLOutputter; ...
    (comp.lang.java)