Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML 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 June 12th, 2003, 07:14 AM
Authorized User
 
Join Date: Jun 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to drdexter33 Send a message via MSN to drdexter33
Default Help with VB XML

Hello...

I have been trying to figure this problem out for days:

--------------------------------------------------------------
SNIPPET
--------------------------------------------------------------
m_strXmlPath = App.Path & "\AUG2003.xml"

'parse XML
Call m_objDOMDays.Load(m_stringXMLPath)

'******START FUNCTION'******
Private Sub populateDayDetails(objSelNode As Node)

Dim objDayElement As IXMLDOMElement
Dim test As IXMLDOMElement

Dim strAttName As String
Dim objChildElement As IXMLDOMElement

If objSelNode Is Nothing Then Exit Sub


'if user clicks on any other node than the day node, ignore
If objSelNode.Tag <> "" Then

'****************************************
'The PROBLEM IS HERE
'****************************************
--> Set objDayElement = m_objDOMDays.nodeFromID(objSelNode.Tag)
'****************************************
For Each objChildElement In objDayElement.childNodes
MsgBox objDayElement.baseName

Next

End If

End Sub
--------------------------------------------------------------
END SNIPPET
--------------------------------------------------------------

The objSelNode.tag = 'n' where n = an attribute say, 1,2,3 which is a day number.

See XML snippet BELOW
--------------------------------------------------------------
SNIPPET
--------------------------------------------------------------
<?xml version="1.0"?>

<month name="Aug">

<day number='1'>
<weekday>Friday</weekday>
<weekdate>1</weekdate>
<event></event>
<eventTime></eventTime>
</day>

</month>
--------------------------------------------------------------
END SNIPPET
--------------------------------------------------------------

The file is parsing in ok, it's just when I try to set the objDayElement equal to the m_objDOMDays.nodeFromID() object [Set objDayElement = m_objDOMDays.nodeFromID(objSelNode.Tag)] that I get the problem.

Thanks!
 
Old June 12th, 2003, 08:28 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

For this to work two things are needed. Firstly number needs to declared as of type ID in the xml file's dtd (schemas not alowed, these were not around when API conceived), secondly (not 100% sure about this) IDs normally must not begin with a digit. They basically have to be like VB variables but can contain other characters midway, e.g. '.', '-'.


--

Joe
 
Old June 24th, 2003, 10:02 PM
Authorized User
 
Join Date: Jun 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try XPath:

Set objDayElement = m_objDOMDays.selectSingleNode("//day[@number='" & objSelNode.Tag & "']")





Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.net, adding XML data to an existing XML file saikoboarder XML 11 April 17th, 2008 04:19 PM
VB xml Programming helgaana1 Beginning VB 6 2 April 10th, 2005 11:03 AM
xml in vb.net redeye2 Pro VB.NET 2002/2003 1 November 10th, 2004 06:48 PM
XML to XML through an XSLT (VB.NET) dimondwoof XSLT 1 June 25th, 2003 12:07 PM
VB and XML rodmcleay XML 0 June 23rd, 2003 10:54 PM





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