This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

importing one xml in another

 
D Preethi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can someone indicate how to exactly import one xml file in another xml file?


Thanks in advance,
Preethi
 
Chinna Eranna
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "Importing an xml into another".

Xml is just a structure rather a language.

 
D Preethi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean, something like, if there are number of small xml files, is there a way I can create one parent xml file which can make use of these files directly? Something like, "import" in Java?
 
Chinna Eranna
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do that.. by introducing a new tag for import of xml's.

Something like..

<Root>
<ChildXml>myChild.xml</ChildXml>
</Root>

Also.. your xml parser should be intelligent enough to identify these.. and take required actions.
 
D Preethi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Can you please point me to some example where there is import of xmls?
 
Chinna Eranna
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have used a similar example.. I shown above in one of our app.

You can also refer an example here..

http://www.xml.com/pub/a/2002/07/31/xinclude.html
 
D Preethi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I looked into those examples but they don't seem to work for me. Can you please point out my mistake? test1.xml and test2.xml look like this:





When I open test1.xml, it just shows -
The Wit and Wisdom of George W. Bush

I have placed both test1.xml and test2.xml in same location. Any idea what I am doing wrong ?
 
Chinna Eranna
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats what I mean to say..

"Your xml parser should be intelligent enough to identify these"
 
pete reisinger
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
D Preethi wrote:Hi All,

Can someone indicate how to exactly import one xml file in another xml file?


Thanks in advance,
Preethi


Hi, I was trying to do the same thing once, first I inserted placeholder in the first xml and then replaced the placeholder with another xml.
But I didn't like it. So after some searching I've done this (it takes to xml strings - envelope and body, and inserts body inside the envelope's <Body></Body> tags):


The code should be self explanatory, but if anything is unclear, or somebody knows how to do it another way (better, easier) let us know.
 
D Preethi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pete.

So, without using the includes tag, there is no way to do the import of the xml files in other xml files, right? XML doesn't support that kind of feature automatically (or by just using entity references) ?



- Preethi

 
pete reisinger
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
what do you mean without using the import tags? In my example you have to xml documents the and only thing you need to know is where you want to insert the second xml file. You can easily change it and insert the second file inside the root tag of the first one etc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic