473,387 Members | 1,578 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,387 software developers and data experts.

grabbing a variable from an XML file

I have a control that transforms an XML file using XSLT.

I also want to grab a particular variable out of the XML file. I thought an
easy way to do this would be no have the XSLT just find the variable, and
write it out as a hidden htmlInputHidden tag. I could then just grab the
value of that HTML tag via the codebehind.

This does not work, and, I assume, it's because I'm trying to both write out
the html AND grab a value in the same page_load...so it's a rather futile
method.

SO...that said, is the best way to just open a xml reader and grab it that
way? The more I type, the more I think I'm probably asking a dumb question
and asking the obvious here. ;o)

-Darrel
Nov 18 '05 #1
2 1244
Hi Darrel:

It sounds like the kind of scenario where the solution might be to
bring the XML into your own XPathNavigator instance. From there you
can find the data you need with something like:

XPathDocument doc = new XPathDocument("<xml filename>");
XPathNavigator navigator = doc.CreateNavigator();
XPathNodeIterator iterator = nav.Select("<xpath expression>");

and also bang it through a transformatio:

XslTransform xslt = new XslTransform();
xslt.Load("<xsl filename>");
// create a writer .. StringWriter HtmlTextWriter...
xslt.Transform(nav, null, writer, null);

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sat, 23 Oct 2004 15:31:41 -0500, "Darrel" <no*****@nospam.com>
wrote:
I have a control that transforms an XML file using XSLT.

I also want to grab a particular variable out of the XML file. I thought an
easy way to do this would be no have the XSLT just find the variable, and
write it out as a hidden htmlInputHidden tag. I could then just grab the
value of that HTML tag via the codebehind.

This does not work, and, I assume, it's because I'm trying to both write out
the html AND grab a value in the same page_load...so it's a rather futile
method.

SO...that said, is the best way to just open a xml reader and grab it that
way? The more I type, the more I think I'm probably asking a dumb question
and asking the obvious here. ;o)

-Darrel


Nov 18 '05 #2
> It sounds like the kind of scenario where the solution might be to
bring the XML into your own XPathNavigator instance. From there you
can find the data you need with something like:
I've actually just started down that path
XPathDocument doc = new XPathDocument("<xml filename>");
XPathNavigator navigator = doc.CreateNavigator();
XPathNodeIterator iterator = nav.Select("<xpath expression>";


I've gotten that far, but hit a snag:

Dim xpd As XPathDocument = New XPathDocument(filename)
'create the associated navigator
Dim xpn As XPathNavigator = xpd.CreateNavigator()
xpn.Select("//template(parent(descendant-or-self::id = '" & pageID & "')")

Here's what I'm trying to do:

The XML is the site navigation. It's hierarchical, obviously. I pass a
'pageID' variable to the page that I then use in the XML transformation to
find out the 'active' link and open up the nodes accordingly.

Another bit of information stored the xml file is the specific template
variable I am using for each page. This template is inherited from the
'parent' node. So, the structure is a bit like this:

items
item
id = 1
template = purple
item
id = 2
item
id = 3

etc.
So, I'd like to be able to open the xml file and find the root item's
template value that belongs to the node with the current active item who's
id = the current value of the page.

(I hope that makes sense ;o)

I *think* my statement needs to be something like this:

//template(parent(descendant-or-self::id = '$currentID'))

Does that look about right? I'm in a bit of a hurry to get out the door, so
my syntax above might be incorrect. That said, the problem is that I'm not
sure how to pass the 'currentID' to the document using an xmlnavigator. I
can do it with the transform, but can I do it with the navigator?

-Darrel
Nov 18 '05 #3

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

Similar topics

3
by: ARGENTINA | last post by:
How do I copy using a php or cgi script a remote xml rss feed into my server? I.E the rss feed: http://www.lanacion.com.ar/herramientas/rss/index.asp?origen=2 Due to restrictions in flash...
4
by: InvisibleMan | last post by:
Hi, Thanks for any help in advance... I'm wondering if anyone knows how or has the resource for graabing a users email address without them knowing? Before I hear all the 'Its not ethical'...
6
by: Jesse Engle | last post by:
i'm working on two client and server programs that send and recieve files using sockets. i saw a c++ example using csockets, and thought i could use the basic idea of what the code was doing to...
0
by: .Net Sports | last post by:
I've been looking everywhere, but i can't locate any functions, or articles on the net or my resources, on how to open a file using vb.net, and then grabbing certain parts of the file, and putting...
29
by: Amer Neely | last post by:
I've got a dynamically built form with checkboxes for each element ( a list of file names in a directory). I need to grab only those checkboxes that are checked, so I can then delete those files. ...
5
by: joe_doufu | last post by:
Hi, old web developer, new to Ajax and XML here. I'm developing an application that grabs an XML file from a (PHP) web service. In fact, it's going to be an online game. When the user clicks a...
22
by: pbd22 | last post by:
Hi. I am building a custom telnet interface and my problem is that I want to read the user input along with the previously written stream. Right now I am logging the user. I have Login:...
1
roswara
by: roswara | last post by:
Dear all, Currently, I am working on a project to make a web-based application using ASP 2.0 and C#. This application will ask user to input for an excel file which has graphs in it. Then the...
0
by: tesis | last post by:
Hi all gurus. This' drivin' me nut: I've already posted this in dotnetframework.setup, having overlooked NG name. Excuse me. I installed Sony EyeToy in my Pc, and grabbing some code on-line,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.