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 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!
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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(...
|
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)
|
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/
|
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.
| |
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,...
|
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...
|
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...
|
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...
|
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...
|
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();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
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...
| |