Wrox Programmer Forums
|
Visual Basic 2008 Professionals For advanced Visual Basic coders working in version 2008. Beginning-level questions will be redirected to other forums,
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 2nd, 2009, 09:26 AM
Authorized User
 
Join Date: Aug 2009
Posts: 18
Thanks: 2
Thanked 0 Times in 0 Posts
Default Problem adding a xml node

Hello everyone!

I'm newbie around here, but i heard that this is a right place for me.
I'm writing a storeyard program with multiple database (XML,MDF,XLS...).
I have a problem with adding a new node (child) in XML file.
Here is code:

Code:
 Private Sub save_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save_btn.Click
        Dim writer As New XmlTextWriter("C:\Documents and Settings\Vladimir\My Documents\Visual Studio 2008\Projects\skladiste_app\sklad.xml", System.Text.Encoding.UTF8)
        writer.WriteStartDocument(True)
        writer.Formatting = Formatting.Indented
        writer.Indentation = 2
        writer.WriteStartElement("article")
        create_node(sybling_count.ToString, name_article_XML.Text, type_article_xml.Text, Cypher_article_xml.Text, num_xml.Text, writer)
        writer.WriteEndElement()
        writer.WriteEndDocument()
        writer.Close()
    End Sub

    Private Sub create_node(ByVal pID As String, ByVal pName As String, ByVal pType As String, ByVal pCyph As String, ByVal pNum As String, ByVal writer As XmlTextWriter)

        writer.WriteStartElement("artikal")
        writer.WriteStartElement("ID_article")
        writer.WriteString(pID)
        writer.WriteEndElement()
        writer.WriteStartElement("Name")
        writer.WriteString(pName)
        writer.WriteEndElement()
        writer.WriteStartElement("Type")
        writer.WriteString(pType)
        writer.WriteEndElement()
        writer.WriteStartElement("Cyphre")
        writer.WriteString(pSyph)
        writer.WriteEndElement()
        writer.WriteStartElement("Number")
        writer.WriteString(pNum)
        writer.WriteEndElement()
        writer.WriteEndElement()
    End Sub
I know there must be an easy way for adding new child to the end of the document. I found some tags for xml but this suppose to be an automatically generated file, so it doesn't work for me.
Those variable names are changed, originally they were in Croatian language, so if you find some irregularity with program flow, ignore it.

Any help is appreciated!

Last edited by Lupus81; August 2nd, 2009 at 09:34 AM..
 
Old August 4th, 2009, 04:56 PM
Authorized User
 
Join Date: Aug 2009
Posts: 18
Thanks: 2
Thanked 0 Times in 0 Posts
Default

It is solved.
Lock this thread.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying data as a Parent Node with Left Node and Right Node Manoj Bisht Visual Basic 2008 Professionals 0 April 2nd, 2009 02:34 AM
VB.net adding data in a selected node saikoboarder XML 9 May 16th, 2008 06:37 AM
VB.net, adding XML data to an existing XML file saikoboarder XML 11 April 17th, 2008 04:19 PM
how to append child node after an node in XML + C# vishnu108mishra XML 5 November 13th, 2007 05:30 AM
Problem in adding the new element into the XML fil Somesh C# 3 February 6th, 2007 06:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.