By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,640 Members | 1,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,640 IT Pros & Developers. It's quick & easy.

recursion xml element?

P: n/a
i have a unusual problem or maybe to me :)

i have a xml file that i need to insert xml element from a string

string - /Box/BoxTest/Test

i have a function that seperate the string out into arraylist and turn it
into string array

string array 0(array index) - "", 1 - Box, 2 - BoxTest, 3 - Test

when first search the xml file if there is no Box as objectname then insert
the xml element from a template xml file

<FacilityPage AnimationInterval="500" BackgroundColor="#FFFFFF"
BackgroundImage="" InstanceNumber="1017" RefreshInterval="10">
<BackwardReferences/>
<DetailPages AllowCreate="1" AllowDelete="1">
</DetailPages>
<FacilityItems AllowCreate="1" AllowDelete="1"/>
<GeneralProperties Attr="0" InstanceNumber="1017" IsConfigured="0"
ObjectName="GROUP" ObjectType="311" SchemaVer="1.4" TraceOptions="">
<Description/>
</GeneralProperties>
</FacilityPage>

i change the attribute of instance number and objectname and the objectname
is Box and this is an xml element inside a xml file. here is the fragment of
the xml file

<FacilityPage AnimationInterval="500" BackgroundColor="#FFFFFF"
BackgroundImage="" InstanceNumber="1094" RefreshInterval="10">
<BackwardReferences/>
<DetailPages AllowCreate="1" AllowDelete="1"/>
<FacilityItems AllowCreate="1" AllowDelete="1"/>
<GeneralProperties Attr="2" InstanceNumber="1094" IsConfigured="0"
ObjectName="HomePage" ObjectType="311" SchemaVer="1.4" TraceOptions="">
<Description><![CDATA[Index page]]></Description>
</GeneralProperties>
</FacilityPage>
<FacilityPage AnimationInterval="500" BackgroundColor="#FFFFFF"
BackgroundImage="" InstanceNumber="1096" RefreshInterval="10">
<BackwardReferences/>
<DetailPages AllowCreate="1" AllowDelete="1"/>
<FacilityItems AllowCreate="1" AllowDelete="1"/>
<GeneralProperties Attr="0" InstanceNumber="1096" IsConfigured="0"
ObjectName="Box" ObjectType="311" SchemaVer="1.4" TraceOptions="">
<Description/>
</GeneralProperties>
</FacilityPage>

the next item on the array BoxTest should go under the Box xml element
between the DetailPage tag as an xml element and so and so for.

does anyone know how to do this?

thank
Sep 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
If I don't misunderstand you are needing to insert an element under another
one and then work with it.
One way to do this is using an XMLDocument with an XPath instruction to
catch the node.
Once obtained the node you can add it atributes, text, etc.

"dotnetnoob" <do********@discussions.microsoft.comwrote in message
news:7B**********************************@microsof t.com...
>i have a unusual problem or maybe to me :)

i have a xml file that i need to insert xml element from a string

string - /Box/BoxTest/Test

i have a function that seperate the string out into arraylist and turn it
into string array

string array 0(array index) - "", 1 - Box, 2 - BoxTest, 3 - Test

when first search the xml file if there is no Box as objectname then
insert
the xml element from a template xml file

<FacilityPage AnimationInterval="500" BackgroundColor="#FFFFFF"
BackgroundImage="" InstanceNumber="1017" RefreshInterval="10">
<BackwardReferences/>
<DetailPages AllowCreate="1" AllowDelete="1">
</DetailPages>
<FacilityItems AllowCreate="1" AllowDelete="1"/>
<GeneralProperties Attr="0" InstanceNumber="1017" IsConfigured="0"
ObjectName="GROUP" ObjectType="311" SchemaVer="1.4" TraceOptions="">
<Description/>
</GeneralProperties>
</FacilityPage>

i change the attribute of instance number and objectname and the
objectname
is Box and this is an xml element inside a xml file. here is the fragment
of
the xml file

<FacilityPage AnimationInterval="500" BackgroundColor="#FFFFFF"
BackgroundImage="" InstanceNumber="1094" RefreshInterval="10">
<BackwardReferences/>
<DetailPages AllowCreate="1" AllowDelete="1"/>
<FacilityItems AllowCreate="1" AllowDelete="1"/>
<GeneralProperties Attr="2" InstanceNumber="1094" IsConfigured="0"
ObjectName="HomePage" ObjectType="311" SchemaVer="1.4" TraceOptions="">
<Description><![CDATA[Index page]]></Description>
</GeneralProperties>
</FacilityPage>
<FacilityPage AnimationInterval="500" BackgroundColor="#FFFFFF"
BackgroundImage="" InstanceNumber="1096" RefreshInterval="10">
<BackwardReferences/>
<DetailPages AllowCreate="1" AllowDelete="1"/>
<FacilityItems AllowCreate="1" AllowDelete="1"/>
<GeneralProperties Attr="0" InstanceNumber="1096" IsConfigured="0"
ObjectName="Box" ObjectType="311" SchemaVer="1.4" TraceOptions="">
<Description/>
</GeneralProperties>
</FacilityPage>

the next item on the array BoxTest should go under the Box xml element
between the DetailPage tag as an xml element and so and so for.

does anyone know how to do this?

thank

Sep 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.