473,804 Members | 3,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help selecting childeren Nodes in ASP

3 New Member
Hi, been a real long time since I have worked in ASP and XML and a neighbor asked me to help him with a web page. I have an XML file that I am trying to search thru and display the children nodes......

Here is a sample of the xml
Expand|Select|Wrap|Line Numbers
  1. <document>
  2.    <MEMBER>
  3.         <ID>000-00-0010</ID>
  4.             <CHARGES>
  5.                 <CHARGE><ChargeDate>06/25/2007</ChargeDate> <Code>BANQ</Code><Desc>BANQUET</Desc> <Amount>0.00</Amount><Note></Note></CHARGE>
  6.                 <CHARGE><ChargeDate>06/25/2007</ChargeDate> <Code>OSR</Code><Desc>RENT</Desc><Amount>0.00</Amount> <Note></Note></CHARGE>
  7.                 <CHARGE><ChargeDate>06/25/2007</ChargeDate> <Code>PR</Code><Desc>POSTAGE REIMBUR</Desc><Amount>0.00</Amount><Note></Note></CHARGE>
  8.                 <CHARGE><ChargeDate>06/25/2007</ChargeDate> <Code>YBS</Code><Desc>YRBK SPONSOR</Desc><Amount>0.00</Amount><Note></Note></CHARGE>
  9.                 <CHARGE><ChargeDate>06/25/2007</ChargeDate> <Code>ZA</Code><Desc>ADMIN.FEE</Desc> <Amount>0.00</Amount><Note></Note></CHARGE>
  10.             </CHARGES>
  11.             <PAYMENT>
  12.                 <PaymentDate></PaymentDate><PaymentAmount>0.00</PaymentAmount>
  13.             </PAYMENT>
  14.     </MEMBER>
  15.     <MEMBER>
  16.         <ID>000-00-0011</ID>
  17.             <CHARGES>
  18.                 <CHARGE><ChargeDate>06/25/2007</ChargeDate> <Code>PC</Code><Desc>SICK COMPER CAP</Desc><Amount>558.00</Amount><Note>10/31/2004</Note></CHARGE>
  19.                 <CHARGE><ChargeDate>06/25/2007</ChargeDate> <Code>ZA</Code><Desc>ADMIN.FEE</Desc><Amount>16.74</Amount> <Note></Note></CHARGE>
  20.             </CHARGES>
  21.             <PAYMENT>
  22.                 <PaymentDate></PaymentDate><PaymentAmount>0.00</PaymentAmount>
  23.             </PAYMENT>
  24.     </MEMBER>
  25.     <MEMBER>
  26.         <ID>000-00-0012</ID>
  27.             <CHARGES>
  28.                 <CHARGE><ChargeDate>06/25/2007</ChargeDate><Code>ZA</Code> <Desc>ADMIN.FEE</Desc><Amount>0.00</Amount><Note></Note></CHARGE>
  29.             </CHARGES>
  30.             <PAYMENT>
  31.                 <PaymentDate></PaymentDate><PaymentAmount>0.00</PaymentAmount>
  32.             </PAYMENT>
  33.     </MEMBER>
  34. </document>
  35.  
  36.  
I have put together this XLS file

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?xml version="1.0"?>
  3. <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  4.     <xsl:template match="/">
  5.         <h1>Charges</h1>
  6.         <table cellpadding="3" cellspacing="0">
  7.             <tr>
  8.                 <th>Charge Date</th>
  9.                 <th>Charge Code</th>
  10.                 <th>Description</th>
  11.                 <th>Amount</th>
  12.                 <th>Note</th>
  13.             </tr>
  14.             <xsl:apply-templates select="//CHARGE"/>
  15.         </table>
  16.     </xsl:template>
  17.     <xsl:template match="CHARGE">
  18.         <tr>
  19.             <td><xsl:value-of select="ChargeDate" /></td>
  20.             <td><xsl:value-of select="Code" /></td>
  21.             <td><xsl:value-of select="Desc" /></td>
  22.             <td><xsl:value-of select="Amount" /></td>
  23.             <td><xsl:value-of select="Note" /></td>
  24.         </tr>
  25.     </xsl:template>
  26. </xsl:stylesheet>
  27.  
  28.  
What I am trying to do is display the charges for say ID = 000-00-0010

Here is the VB script I am trying to use.....

Expand|Select|Wrap|Line Numbers
  1. function transformDetailXML( XML, XSL, strDetail ) 
  2.     Dim objXML
  3.     Dim objXSL
  4.     Dim objNode
  5.     'dim objCharges
  6.  
  7.     Set objXML = getXMLDoc(XML)
  8.     Set objNode = objXML.SelectSingleNode("document/MEMBER/ID/[text()='" & strDetail & "']")
  9.     'Set objCharges = objNode.selectNodes("/CHARGES[CHARGE]")
  10.  
  11.     Set objXSL = getXMLDoc(XSL)        
  12.     If objXML.parseError <> 0 Then Response.Write reportParseError(objXML.parseError)
  13.     If objXSL.parseError <> 0 Then Response.Write reportParseError(objXSL.parseError)
  14.  
  15.     transformDetailXML = objNode.transformNode(objXSL)
  16. End Function
  17.  
  18.  
And lastly, this is what is showing in my browser....

Searching Mode
<ID>000-00-0010</ID>

Thanks in advance for your help.....
Jun 26 '07 #1
4 1758
Dököll
2,364 Recognized Expert Top Contributor
Hello, tfhanson!

I would like to get as much information from you as possible so when I move this thread you get what you need quicker. I think we need to make sure of some things first

Can you tell me if you you know whether the XSL appropriately communicate with the XML file?

You will need to get that working first so if you have a problem you'll know where it is coming from.

Also, it might be helpful to you to indent your code in such a way to make it easier to read.

I will try your code in HTML to see what it does...
Jun 27 '07 #2
tfhanson
3 New Member
Yes, when I use the xml and xls files to show everything, it works fine... What I need to do is only show the charges for a particular Member.
Jun 27 '07 #3
tfhanson
3 New Member
Thanks for looking, I solved it with straight vbscript, although I would still like to know how to do it with XLS

Here is what solved it for me....



xmlDoc = "exporting. xml"

strDetail = "000-00-0010"

Set objXML = getXMLDoc(xmlDo c)
Set objNodeList = objXML.getEleme ntsByTagName("d ocument/MEMBER[ID='" & strDetail & "']/CHARGES/CHARGE")

numberofitems = objNodeList.len gth

For i = 0 To numberofitems - 1

Set objHdl = objNodeList.ite m(i)
Response.Write objHdl.childNod es(0).text & " " & objHdl.childNod es(1).text & " " & objHdl.childNod es(2).text & " " & objHdl.childNod es(3).text & " " & objHdl.childNod es(4).text & "<br>"

Next
Jun 27 '07 #4
paragguptaiiita
21 New Member
ctually i have a large XML file and i also made a XSL file for viewing that XML file on the web browser.When we view that XML file in web browser and edit that file then i want to update that XML file also.(here we can use any scripting language for updating )

i don't know how it will, i saw this link Check this

In this ASP is used for updating the XML file.I want the same thing but the problem is here the XML file is very small and file that i have is so large in which each node contains 3-4 attributes and 3-4 child also and each child also contains 3-4 attribute,this same thing is repeated many times in the file.

Can u give me ur mail id so i can send my XML file and XSL file
Feb 11 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2973
by: kj | last post by:
Suppose I have some XML document that contains tags of the form <... xmlns:foo="http://www.bar.org/foo"> <... xmlns:foo="baz"> <... xmlns:frobozz="http://www.bar.org/foo"> What's the XPath expression to select the namespace nodes with prefix "foo"? And what's the XPath expression to select the
2
15155
by: Mike Kamermans | last post by:
I'm having some trouble using text() in an xsl:value-of xpath. I have the following xml: .... <graphemes> <grapheme>1</grapheme> <grapheme>2</grapheme> <grapheme>3</grapheme> </graphemes> ....
2
1567
by: Dag | last post by:
Hi I am pretty much an xml beginner; hopefully someone can easily answer this one... I want to select a node representing a worksheet in an xml document for the Office Web Components spreadsheet. The file uses xml namespaces, of which I know very little. But it does seem clear that I can't select the <ss:Worksheet> element by name only; the xpath "//Worksheet" does not match any nodes Extract from the file, in case this is needed to come...
4
24260
by: JoKur | last post by:
I'm currently using a context menu to allow the user to add, rename and delete nodes in a treeview control. When a node is added we give it a bogus name ("NewNode") and invoke the add method. We would then to then select the newly added node and rename it but can't figure out how to select the node via code. How do you select a node from code when you don't know the index? -- Thanks
1
1754
by: Stefan | last post by:
Hey guys ! Can someone pls help me and tell me how it is possible to Select a Node in 2nd row? I got a treeview which is build like follows: node2.Nodes.Add("blah", "blubb"); node1.Nodes.Add(node2);
2
7503
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView nodes. The TreeView populates dynamically as there are a significant number of nodes. The DataGrid displays both the items and the nodes from the TreeView. Using the explorer analogy this means the TreeView shows folders, and the DataGrid folders...
3
6285
by: Yoav Shapira | last post by:
Hi, I have a well-formed XHTML document that, among other content, has the following segment: <img src="uniqueUrl1" /> <p>some text</p> <p>some other text</p> <p>some more text</p> <img src="uniqueUrl2" />
2
4071
by: dav61000 | last post by:
I am new to VB.net so I am not sure if there is a good way to do this or not but here is my problem. I have created a form with a TreeView control on it. When the user selects a node from the treeview I would like to use the AFTER_SELECT method to bring up a new form if possible containing a dataset for the record selected. OR as an alternative I would like to bring up a dataset for that record selected on the same form. I have succeeding in...
1
3553
by: Alexey Titov | last post by:
Hi :) I need help selecting particular nodes with the SelectChildren method I get a simple xml from the web (excerpt): <ab:store> <ab:goods> <ab:icecream> <ab:flavor_01>
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.