473,396 Members | 2,076 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,396 software developers and data experts.

XML Problem - Urgent

Dear Sir,

I have a problem while parsing my XML file. I can read all nodes except the one called "Color".
I have a node called "Color" with an attribute "l" to determine the language is frensh or english.

Can anyone help me ?
Thank you.

Paul

Here's my code in VB.Net

Expand|Select|Wrap|Line Numbers
  1.             Dim doc As XmlDocument = New XmlDocument
  2.             Dim v_nodelist As XmlNodeList
  3.  
  4.             doc.Load(Server.MapPath("book5.xml"))
  5.  
  6.             'Create an XmlNamespaceManager for resolving namespaces.
  7.             Dim v_expression As String = String.Format("//{0}:Books", "ns1")
  8.             Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(doc.NameTable)
  9.             nsmgr.AddNamespace("ns1", "http://www.starstandards.org/STAR")
  10.             nsmgr.AddNamespace("oa", "http://www.openapplications.org/oagis")
  11.             nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
  12.             nsmgr.AddNamespace("schemaLocation", "http://www.starstandards.org/STAR/STAR/Rev1.1/BODs/ListVehicleInventory.xsd")
  13.  
  14.             'Create a new XmlDocument for the specified source file and load it.
  15.             'v_nodelist = v_xmld.SelectNodes("/ListVehicleInventory/DataArea/VehicleInventory/Invoice/Vehicle")
  16.             v_nodelist = doc.SelectNodes(v_expression, nsmgr)
  17.  
  18.             'Select the book node with the matching attribute value.
  19.             Dim v_color_fr As String
  20.             Dim v_color_en As String
  21.             Dim v_id As String
  22.             Dim v_title As String
  23.             Dim v_node As XmlNode
  24.             Dim root As XmlElement = doc.DocumentElement
  25.             Dim v_nodelistColor As XmlNodeList
  26.  
  27.  
  28.             'Loop through the nodes
  29.             For Each v_node In v_nodelist
  30.  
  31.                 ' ID
  32.                 If v_node.Item("ID") Is Nothing Then
  33.                     v_id = "" 
  34.                 Else
  35.                     v_id = v_node.Item("ID").InnerText
  36.                 End If
  37.  
  38.                 ' Title
  39.                 If v_node.Item("Title") Is Nothing Then
  40.                     v_title = ""
  41.                 Else
  42.                     v_title = v_node.Item("Title").InnerText
  43.                 End If
  44.  
  45.  
  46.                 v_nodelistColor = v_root.SelectNodes("//ns1:List/Books/Color", nsmgr)
  47.  
  48.                 For Each v_nodeS In v_nodelistColor
  49.  
  50.                     ' Color Fr
  51.                     v_nodeS = v_root.SelectSingleNode("//ns1:Color[@l='fr']", nsmgr)
  52.                     If Not v_nodeS Is Nothing Then
  53.                         v_color_fr = CType(v_nodeS.InnerText, String)
  54.                     Else
  55.                         v_color_fr = ""
  56.                     End If
  57.  
  58.                     ' Color En
  59.                     v_nodeS = v_root.SelectSingleNode("//ns1:Color[@l='en']", nsmgr)
  60.                     If Not v_nodeS Is Nothing Then
  61.                         v_color_en = CType(v_nodeS.InnerText, String)
  62.                     Else
  63.                         v_color_en = ""
  64.                     End If
  65.  
  66.                 Next
  67.  
  68.                 Response.Write("ID : " & v_id & " - Title : " & v_titre & " - Color Fr : " & v_color_fr & " - Color En : " & v_color_en & "<BR>")
  69.                 v_color_fr = ""
  70.                 v_color_en = ""
  71.  
  72.             Next
XML Data File
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <bookstore  xmlns="http://www.starstandards.org/STAR" 
  3.             xmlns:oa="http://www.openapplications.org/oagis" 
  4.             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  5.             xsi:schemaLocation="http://www.starstandards.org/STAR/STAR/Rev1.1/BODs/ListVehicleInventory.xsd">
  6.     <List>
  7.         <Books>
  8.             <ID>BK10001</ID>
  9.             <Title>Harry Potter</Title>
  10.             <Color l="fr">Blanc</Color>
  11.             <Color l="en">White</Color>
  12.         </Books>
  13.         <Books>
  14.             <ID>BK20002</ID>
  15.             <Title>Manuella</Title>
  16.             <Color l="fr">Jaune</Color>
  17.             <Color l="en">Yellow</Color>
  18.         </Books>
  19.         <Books>
  20.             <ID>BK30003</ID>
  21.             <Title>Charlie's angels</Title>
  22.             <Color l="fr">Noir</Color>
  23.             <Color l="en">Black</Color>
  24.         </Books>
  25.         <Books>
  26.             <ID>BK30004</ID>
  27.             <Title>Charlie's angels</Title>
  28.             <Color l="en">Green</Color>
  29.         </Books>
  30.     </List>
  31. </bookstore>
Sep 5 '06 #1
0 1354

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

Similar topics

3
by: Rob | last post by:
I have a form - when you click the submit button, it appends a variable to the URL (e.g. xyz.cgi?inputID=some_dynamic_variable) It also opens a new page. Now, that some_dynamic_variable is...
9
by: Stefan Bauer | last post by:
Hi NG, we've got a very urgent problem... :( We are importing data with the LOAD utility. The input DATE field data is in the format DDMMYYYY (for days) and MMYYYY (for months). The target...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
28
by: Tamir Khason | last post by:
Follwing the struct: public struct TpSomeMsgRep { public uint SomeId;
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
7
by: zeyais | last post by:
Here is my HTML: <style> ..leftcolumn{float:left;width:300px;border: 1px solid #ccc} ..rtcolumn{float:left;width:600px;border: 1px solid #ccc} </style> <body> <div class="leftcolumn"...
33
by: dembla | last post by:
Hey Frnds can anyone help me in this i need a program in 'c' PROGRAM to print NxN Matrix 9 1 8 1 2 3 2 7 3 as 4 5 6 6 4 5 7 8 9 in sorted form
8
by: ginnisharma1 | last post by:
Hi All, I am very new to C language and I got really big assignment in my work.I am wondering if anyone can help me.........I need to port compiler from unix to windows and compiler is written...
3
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from...
7
by: Cirene | last post by:
I used to use the Web Deployment Project with my VS2005 projects. Now I've fully upgraded to VS2008. Do I have to download a new version of the Web Deployment Project? If so where can I find...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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...
0
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...
0
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,...

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.