• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

structure

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
suppose if i have an xml file in the form
<master>
<element1/>
<element2>aaa</element2>
</master>
how do i get this in form
<master element1 element2/>

thanx
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Er, at the risk of being told that I don't understand XML...
Surely the thing you want to do would break the XML. If you want to use the <MyElement /> syntax (avoiding </MyElement> ; ) , you can only do so if the element has no child elements. It can have attributes, but cannot contain elements.
So, no XML package is likely to be able to do what you say, because it's not an XML operation. If you really need to do what you say, it would have to be done by ordinary Java text manipulation.
[ November 25, 2002: Message edited by: Peter Chase ]
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agreed.
<master element1 element2/> is not well-formed XML syntax.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess Anil wants the output to look like -
<master element1="" element2="aaa" />
Is it right Anil?
Thanks,
Dan
 
Anil HN
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Dan I want the o/p to look like

<master element1="" element2="aaa" />
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please have a look at - https://coderanch.com/t/146746/po/certification/xPath-questions
Cheers,
Dan
 
You learn how to close your eyes and tell yourself "this just isn't really happening to me." Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic