473,772 Members | 3,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Just two quick questions

Dear everyone,
I managed to get most of my code (nesting documents etc.) worked out,
but there are a few niggles.

The first one is as follows:

My first document is:

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<WfMessage>
<ATO_ATO>
<ATO_FileLoaded IntoSystem>No</ATO_FileLoadedI ntoSystem>
<ATO_RawXML>X ML DATA HERE</ATO_RawXML>
</ATO_ATO>
</ProcInstInputDa ta>
</ProcessTemplate Execute>
</WfMessage>

What I want to do is to insert my second XML file between the tags so that
it reads:

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<WfMessage>
<ATO_ATO>
<ATO_FileLoaded IntoSystem>No</ATO_FileLoadedI ntoSystem>
<ATO_RawXML>
<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
(XML data in here...snipped for brevity)
</ATO_RawXML>
</ATO_ATO>
</ProcInstInputDa ta>
</ProcessTemplate Execute>
</WfMessage>

(By the way, I do need the second root in the nested document!)
I've come up with some code that comes up with the following XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<WfMessage>
<ATO_ATO>
<ATO_FileLoaded IntoSystem>No</ATO_FileLoadedI ntoSystem>
(data in here...snipped for brevity) // TAGS AND ROOT MISSING !!!
</ATO_ATO>
</ProcInstInputDa ta>
</ProcessTemplate Execute>
</WfMessage>

Which is nearly what I need when I use the following code:

ATO_document = builder.parse( "D:\\ATO.xm l" );
XML_document = builder.parse( "D:\\XML.xm l" );
NodeList replacedNodeLis t = XML_document.ge tElementsByTagN ame("ATO_RawXML ");
Node foundnode = replacedNodeLis t.item(0);
if ( foundnode != null )
{
Node modfiedReplaced Document = replaceNode(XML _document, ATO_document,
foundnode);}
else
{
// error message here.
}
}
and replaceNode is defined as follows:

public static Node replaceNode(Doc ument replacedDocumen t, Document
replacingDocume nt, Node replacedNode)
{
//Create a documentFragmen t of the replacingDocume nt

DocumentFragmen t docFrag = replacingDocume nt.createDocume ntFragment();
Element rootElement = replacingDocume nt.getDocumentE lement();
docFrag.appendC hild(rootElemen t);

//Import docFrag under the ownership of replacedDocumen t

Node replacingNode =
((replacedDocum ent).importNode (docFrag, true));

//In order to replace the node need to retrieve replacedNode's parent

Node replaceNodePare nt = replacedNode.ge tParentNode();
replaceNodePare nt.replaceChild (replacingNode, replacedNode);
return replacedDocumen t;
}

I've tried using insertBefore functions in the replaced document to
artificially recreate the <ATO_RawXML> tags, but the code
grumbles that the parent element is missing. I'm sure a solution is very
simple
but I am losing my hair over this. Can anyone suggest anything (other than
a lotion to keep my hair in) ?

Best wishes
Paul

Jul 20 '05 #1
2 1615
In article <40********@bae n1673807.greenl nk.net>,
Horny Porno-thologist <pa********@aes ystems.com> wrote:
What I want to do is to insert my second XML file between the tags so that
it reads: <ATO_RawXML>
<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
(XML data in here...snipped for brevity)
</ATO_RawXML>


You can't do this. An xml declaration may only occur at the start of
a document. There is no way to have it embedded inside another
document.

-- Richard
--
Spam filter: to mail me from a .com/.net site, put my surname in the headers.

FreeBSD rules!
Jul 20 '05 #2
Thanks Richard,

Now all I have to do is solve the second problem - the tag being
replaced. I can see why it is doing this, but I don't know how
to circumvent the problem, unless it requires regenerating the
"missing" tag.... can anyone suggest a very easy way of doing this?

Best wishes

Paul
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2076
by: Elaine Jackson | last post by:
Two quick newbie questions: 1) Does Python have passing-by-reference? 2) In ordinary parlance, "deep" implies "shallow" but not conversely. In the Python "copy" module (if I understand correctly), the implication goes the other way. Do you find this a nuisance? Peace, EJ
1
1534
by: YT | last post by:
Couple of quick ASP (3.0) Cookie questions: 1/ I'm using a cookie in my asp script to place cookies (within a key) so my code looks like: Response.Cookies( "quoteform" )( "name" ) = Session( "name" ) Response.Cookies( "quoteform" )( "organization" ) = Session( "organization" ) Response.Cookies( "quoteform" )( "address1" ) = Session( "address" ) Response.Cookies( "quoteform" )( "address2" ) = Session( "suite" ) Response.Cookies(...
8
5377
by: Dutchy | last post by:
Dear reader, In an attempt to obtain the path to the quick-launch-folder in order to create a shortcut to my application-updates during installation , I thought to: 1- check if quick launch is used by the user 2- check if a link to my application is there 3- if so, obtain the path (ANY PATH) to the quick-launch-folder from existing button(s)
0
2587
by: netguru7575 | last post by:
All Quick Test Professional (QTP) FAQs QuickTest Professional (QTP) Questions and Answers Part # 1 http://softwareqatestings.com/content/view/188/38/
6
5446
by: SuperDuper | last post by:
Just a few quick questions. 1) How would I count the length of words in 5 certain strings. SomeString.s1, SomeString.s2, etc.. 2) How to compute the average word length? 3) How to compute the standard deviation (without duplicating code) 4) How to do all of this without duplicating the code for each String.
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10104
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.