473,395 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Adding a node in xml

N9
Hi,

I got a xml fil:

<Ordbog ModuleId="4">
<WordSet Id="cec36468-a624-46af-a51e-e583f52efab6" />
<Ord>return</Ord>
<Beskrivelse>
test1
</Beskrivelse>
<WordSet Id="009f4be5-0481-4a04-a8d2-f817c7e6d48e" />
<Ord>tow</Ord>
<Beskrivelse>
Fem
</Beskrivelse>
<WordSet Id="c7b6ae0e-1f74-43d3-839b-24a39f259cb6" />
</Ordbog>

I like to adding a node with xslt, so the result looks like that.

<Ordbog ModuleId="4">
<Ord>
<WordSet Id="cec36468-a624-46af-a51e-e583f52efab6" />
<Ord>return</Ord>
<Beskrivelse>
test1
</Beskrivelse>
</Ord>
<Ord>
<WordSet Id="009f4be5-0481-4a04-a8d2-f817c7e6d48e" />
<Ord>tow</Ord>
<Beskrivelse>
Fem
</Beskrivelse>
<WordSet Id="c7b6ae0e-1f74-43d3-839b-24a39f259cb6" />
</Ord>
</Ordbog>

It's that possible ??

regards
N9
Jun 27 '08 #1
1 1307
It's that possible ??

To "add a node" in XSLT, start with the identity transformation (see any
decent XSLT tutorial), then add a template which expresses the exception
to that copy-without-changing process. In this case, you'd add a
template to wrap the content of Ordbog in an additional Ord element:

<xsl:template select="Ordbog">
<ord>
<xsl:apply-templates>
</ord>
</xsl:template>

or something of that sort. (Remember, this has to appear IN ADDITION to
the identity template, since that handles all the other cases.)

Note that this generates a new document with the desired change, rather
than directly altering the original document. Replacing the old document
with the new one is your responsibility.
Jun 27 '08 #2

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

Similar topics

2
by: Maersa | last post by:
hi, i'm trying to add "attributes" to some nodes and it works at design time but fails at runtime. XmlDocument doc = new XmlDocument(); XmlElement elem = doc.CreateElement( "root" );...
2
by: Keith M | last post by:
Hi, I have found a very useful piece of code in the msdn which shows how to load an xml config file, search for a particular value and replace it. Could someone possibly convert it to C# from...
5
by: CR | last post by:
I've been to figure out how to get AddSortLast function to add nodes in acsending order (a b c d) I figured it out how to get it to sort in decending order but I can't get it to sort in acsending...
9
by: James Geurts | last post by:
Hey all... I posted this in the vs.net ide group too, but people are not answering, so I figured that it might be more appropriate here. I'm not sure if I'm adding a designer to my code properly. ...
3
by: MrNobody | last post by:
Ok, so I'm absoultely positive this was working last night, but today I'm getting this error in my program when I try to add a child node to a parent node of a tree... The error says: ...
3
by: Brian Henry | last post by:
If i already have a tree view created, and want to add another new node to it, how would i do so? Is there a way to throught tags or anything? like i have this RootNode | +-- Child 1 +--...
0
debasisdas
by: debasisdas | last post by:
Select Microsoft windows common controls 6.0 (SP6) from components Add a TreeView control to the form. Add a ImageList control to the form. Add some bitmaps to the imagelist. Set the name of...
6
by: SQACSharp | last post by:
I'm using the EnumChildWindows API with an EnumChildWndProc callback to populate the treeview. The output will be something similar to spy+ + How can I specify the parent when adding a new node...
1
by: Bart Steur | last post by:
Hi As a VB6 user I'm unfamiliar with the Treeview control of VB2005. I read it was changed but I have a hard time finding the right help/samples for my problem. In VB6 you had 1 collection,...
60
by: Bill Cunningham | last post by:
I have a row of values like such, placed in a text file by fprintf. 10.50 10.25 10.00 10.75 11.00 What I want to do to the above colum is add a new column right beside it which is a total...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.