Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi ,

I have a ASP.Net 1.1 application that uses an XML file (AppConfig.xml) to read configuration parameters

The XML file looks like this

 

<AppParameters>

<Global>

<Parameter1 value="1000" />

<Parameter2 value="True" />

<Parameter3 value="Approve" />

 

</Global>

<OrderList>

<ShowCol6 value="True" />

<ShowCol7 value="False" />

<ShowCol8 value="False" />

<OrderList>

 

<DeliveryList>

<Parameter1 value="True" />

<Parameter2 value="True" />

<Parameter3 value="500" />

</DeliveryList>

</AppParameters>

 

It has multiple sections (a section for each application module). Each section has different parameters.

 

I want to have a ASP.net page that will LOAD and DISPLAY all theses parameters.

I want to be able to modify them and SAVE them back to the XML file

 

Basically what I am looking for is to recursively read an XML file that has the above structure and be able to update each Parameter.

 

Thanks for ur help

When you gotta go,you gotta go !!!!!!!
Posted

i haven't done anything with xml and webpages yet, but have some experience with xml, so I'm going to take a stab at the xml part only. You'll need help from someone else on the web part.

 

Not sure how much Xml experience you have so I'm going to over-explain this.

 

if your x file is as above, meaning you're not nesting groups inside of groups, then all you need is an xml node list, and you're not going to need recursion.

 

In your file specifically, "AppParameters" is your root node. So, to select every child node to that, you say:

'load xdoc, etc here
...
'this part gets your root node; XML IS case sensitive!!!
Dim xn as XmlNode
xn = xDoc.selectSingleNode("//AppParameters")

'this part gets the child nodes. each child will include all subnodes, 
'so it will look like this:
'<Global>
'  <Para....
'</Global>
Dim xl as XmlNodeList
xl = xDoc.ChildNodes

'Now you can iterate through each node:
For each xn in xl
'  do your display work here
Next xn

 

If you sometimes have grandchildren that are also groups, then you're going to have to use recursion, but i'm skipping that for now. If you do have that and run into problems, let me know.

Posted (edited)

Also, here's some handy XML links.

 

A few good, semi-short tutorials:

 

A quick-ref for XPath query syntax, part of the xpath tutorial above:

 

And finally, an extremely handy tool, jEdit. It's an open source extensible text editor, and does wonders with Xml Docs. Get it here:

http://www.jedit.org

 

You'll want these plug-ins at a minimum:

  • XML
    checks your xdoc for correct structure, adds text coloring, etc.
  • XQuery Plugin
    lets you run queries against xdocs and displays the outputs; a few different options for source doc and output location. Yes, Plugin is part of it's name ;-)
  • SideKick
    displays your xdoc in a tree
  • Beauty
    auto-indents your document
  • BufferTabs
    adds a little more control and nice features to the buffer

Some of those have other required plugins, obviously take them as well. It will tell you on the site.

 

And finally, sorry if you already knew all of this and I overexplained it.

Edited by alreadyused

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...