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

Cannot read the XML file if there is schema

LWU
Here is the XML file:
<?xml version="1.0" encoding="UTF-8" ?>
- <CTMS xmlns="ctms-20.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="ctms-20.xsd
http://www.clinphone.com/schema/CTMS-20.xsd" transferType="Incremental"
transferId="-1" previousTransferId="-1"
creationDateTime="2006-10-13T01:01:01" metaDataVersion="1.0">
- <StudyData studyId="HGS1006C1056">
- <SubjectManagement countryId="USA" siteId="US123" patId="991001"
messageType="Screening Details">
- <CTMS_Terms>
<DateOfBirth>16-DEC-2006</DateOfBirth>
<DateOfScreening>2006-10-12T01:01:01</DateOfScreening>
<Gender>M</Gender>
</CTMS_Terms>
</SubjectManagement>
</StudyData>
- <AuditRecord>
<UserRef>CLP</UserRef>
<LocationRef>GRB</LocationRef>
<DateTimeStamp>2006-10-13T01:01:01</DateTimeStamp>
<ReasonForChange>Automated Update</ReasonForChange>
<SourceId>0</SourceId>
</AuditRecord>
</CTMS>

---End of XML File

And My question is I would like to parse the studyId, and countryId,
sitId, patId and messageType, and DateOfBirth and DateOfScreening.
My code is the following:
m_xmld = New XmlDocument()
m_xmld.Load(xmlFile)
Dim ncsi As New XmlNamespaceManager(m_xmld.NameTable)
ncsi.AddNamespace("foo", "ctms-20.xsd")
ncsi.AddNamespace("xsi",
"http://www.w3.org/2001/XMLSchema-instance")

m_nodelist1 = m_xmld.SelectNodes("/CTMS/StudyData", ncsi)
For Each m_node1 In m_nodelist1
studyIdAttribute =
m_node1.Attributes.GetNamedItem("studyId").Value
Next
m_nodelist2 =
m_xmld.SelectNodes("/CTMS/StudyData/SubjectManagement")
For Each m_node2 In m_nodelist2
countryIdAttribute =
m_node2.Attributes.GetNamedItem("countryId").Value
siteIdAttribute =
m_node2.Attributes.GetNamedItem("siteId").Value
patIdAttribute =
m_node2.Attributes.GetNamedItem("patId").Value
mtAttribute =
m_node2.Attributes.GetNamedItem("messageType").Val ue
Next
m_nodelist3 =
m_xmld.SelectNodes("/CTMS/StudyData/SubjectManagement/CTMS_Terms")
For Each m_node3 In m_nodelist3
DOB = m_node3.ChildNodes.Item(0).InnerText
SEX = m_node3.ChildNodes.Item(1).InnerText
Next
m_nodelist4 = m_xmld.SelectNodes("/CTMS/AuditRecord")
For Each m_node4 In m_nodelist4
UserRef = m_node4.ChildNodes.Item(0).InnerText
LocationRef = m_node4.ChildNodes.Item(1).InnerText
DateTimeStamp = m_node4.ChildNodes.Item(2).InnerText
ReasonForChange = m_node4.ChildNodes.Item(3).InnerText
SourceId = m_node4.ChildNodes.Item(4).InnerText
Next
---End of Code
I alwasy get back the empty string for all nodes and all elements.
Any help....

Nov 22 '06 #1
3 2033
LWU wrote:
Here is the XML file:
<?xml version="1.0" encoding="UTF-8" ?>
- <CTMS xmlns="ctms-20.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="ctms-20.xsd
http://www.clinphone.com/schema/CTMS-20.xsd" transferType="Incremental"
transferId="-1" previousTransferId="-1"
creationDateTime="2006-10-13T01:01:01" metaDataVersion="1.0">
- <StudyData studyId="HGS1006C1056">
- <SubjectManagement countryId="USA" siteId="US123" patId="991001"
messageType="Screening Details">
- <CTMS_Terms>
<DateOfBirth>16-DEC-2006</DateOfBirth>
<DateOfScreening>2006-10-12T01:01:01</DateOfScreening>
<Gender>M</Gender>
</CTMS_Terms>
</SubjectManagement>
</StudyData>
- <AuditRecord>
<UserRef>CLP</UserRef>
<LocationRef>GRB</LocationRef>
<DateTimeStamp>2006-10-13T01:01:01</DateTimeStamp>
<ReasonForChange>Automated Update</ReasonForChange>
<SourceId>0</SourceId>
</AuditRecord>
</CTMS>

---End of XML File

And My question is I would like to parse the studyId, and countryId,
sitId, patId and messageType, and DateOfBirth and DateOfScreening.
My code is the following:
m_xmld = New XmlDocument()
m_xmld.Load(xmlFile)
Dim ncsi As New XmlNamespaceManager(m_xmld.NameTable)
ncsi.AddNamespace("foo", "ctms-20.xsd")
ncsi.AddNamespace("xsi",
"http://www.w3.org/2001/XMLSchema-instance")

m_nodelist1 = m_xmld.SelectNodes("/CTMS/StudyData", ncsi)
m_nodelist1 =
m_xmld.SelectNodes("/foo:CTMS/foo:StudyData", ncsi);
For Each m_node1 In m_nodelist1
studyIdAttribute =
m_node1.Attributes.GetNamedItem("studyId").Value
Next
m_nodelist2 =
m_xmld.SelectNodes("/CTMS/StudyData/SubjectManagement")
m_xmld.SelectNodes("/foo:CTMS/foo:StudyData/foo:SubjectManagement")

Use that prefix in XPath expressions.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 22 '06 #2
"LWU" <wu*******@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Here is the XML file:
<?xml version="1.0" encoding="UTF-8" ?>
- <CTMS xmlns="ctms-20.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="ctms-20.xsd
http://www.clinphone.com/schema/CTMS-20.xsd" transferType="Incremental"
transferId="-1" previousTransferId="-1"
creationDateTime="2006-10-13T01:01:01" metaDataVersion="1.0">
- <StudyData studyId="HGS1006C1056">
....
</StudyData>
....
</CTMS>

---End of XML File

And My question is I would like to parse the studyId, and countryId,
sitId, patId and messageType, and DateOfBirth and DateOfScreening.
My code is the following:
m_xmld = New XmlDocument()
m_xmld.Load(xmlFile)
Dim ncsi As New XmlNamespaceManager(m_xmld.NameTable)
ncsi.AddNamespace("foo", "ctms-20.xsd")
ncsi.AddNamespace("xsi",
"http://www.w3.org/2001/XMLSchema-instance")

m_nodelist1 = m_xmld.SelectNodes("/CTMS/StudyData", ncsi)
If you specify "foo" for the namespace prefix in the AddNamespace, then you
have to use foo:. Try /foo:CTMS/foo:StudyData.

John
Nov 22 '06 #3
LWU
This is WORKING...
You guys awesome..
John Saunders wrote:
"LWU" <wu*******@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Here is the XML file:
<?xml version="1.0" encoding="UTF-8" ?>
- <CTMS xmlns="ctms-20.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="ctms-20.xsd
http://www.clinphone.com/schema/CTMS-20.xsd" transferType="Incremental"
transferId="-1" previousTransferId="-1"
creationDateTime="2006-10-13T01:01:01" metaDataVersion="1.0">
- <StudyData studyId="HGS1006C1056">
...
</StudyData>
...
</CTMS>

---End of XML File

And My question is I would like to parse the studyId, and countryId,
sitId, patId and messageType, and DateOfBirth and DateOfScreening.
My code is the following:
m_xmld = New XmlDocument()
m_xmld.Load(xmlFile)
Dim ncsi As New XmlNamespaceManager(m_xmld.NameTable)
ncsi.AddNamespace("foo", "ctms-20.xsd")
ncsi.AddNamespace("xsi",
"http://www.w3.org/2001/XMLSchema-instance")

m_nodelist1 = m_xmld.SelectNodes("/CTMS/StudyData", ncsi)

If you specify "foo" for the namespace prefix in the AddNamespace, then you
have to use foo:. Try /foo:CTMS/foo:StudyData.

John
Nov 22 '06 #4

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

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
9
by: Rob Mayo | last post by:
I have a bunch of XSD files in my assembly as embedded content that are read out via reflection and streams. My app creates the XML on the fly, and I want to validate it using the schema files...
2
by: Ian Emery | last post by:
Hi, I am trying to validate an XML file using the XmlValidatingReader and XmlUrlResolver. The code for which goes like this: // Read the XML file. XmlTextReader xmlReader = new XmlTextReader(...
4
by: Stefan Rotter | last post by:
Hi, I'm trying to load a schema into an XmlSchema object with the Read and Compile methods. I use Read with a ValidationEventHandler. No errors occurs but when I look at the XmlSchema properties...
2
by: PeterW | last post by:
I have an xml file from which I want to generate an xsd schema and at a later stage a cs class. The xml file has a mix of defined namespaces and also an empty namespace. These are defined as...
3
by: ciaran.mchale | last post by:
Hi folks, I downloaded the binary version of Xerces C++ 2.7.0 for Windows and am using it to help me get up to speed with XML and XML Schema. So please excuse me if this is a "novice" question....
1
by: techie | last post by:
Hi, I am using an xml schema (Schema1.xsd) which refers to two other Schemas as follows. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:plcm-s="http://www.mycompany.com/plcm"...
1
by: BillAtWork | last post by:
Hi, I'm trying to validate an XML document against an XSD schema and I receive the following error: ---------- MyCode.CreateValidRequest : System.Web.Services.Protocols.SoapException :...
1
by: BillAtWork | last post by:
Hi, I'm trying to validate an XML document against an XSD schema and I receive the following error: ---------- MyCode.CreateValidRequest : System.Web.Services.Protocols.SoapException :...
5
by: carlpayne1984 | last post by:
Hi all, I'm fairly new to XML, however already I have studied myself stupid without being able to solve this problem. Basically, I have an XML file/Schema about a CD catalog that I've created that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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
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
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...

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.