473,387 Members | 1,903 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.

Parsing XML content

Hi, I hope this is the right place to ask.

I have an xml file thus:

<?xml version="1.0" encoding="UTF-8"?>
<Message xmlns="urn:myurl-org:ns2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:myurl-org:ns2
...\Schemas\schema.xsd" type="Message">
<id root="7DC0FFE7-1224-4598-8F20-3B7662D416A1"/>
<creationTime value="2004"/>
<acknowledgement typeCode="AE">
<messageRef>
<id root="04074443-DE90-4FE8-9D4A-DBF9A7E81FFA"/>
</messageRef>
</acknowledgement>
</Message>

I wish to be able to parse the file such that I can return the root
attribute of the id node within messageRef.

Unfortunately, I cannot do this using msxml. getElementByTagName doesn't
work because a default namespace is provided. In fact, I cannot loop through
the nodes either, as msxml only suggests the document has one node <Message
/>, but no children.

I am considering swapping over from VB6 to VB.NET to accomplish this task,
as I've heard the system.xml namespace contains a revised implementation of
the DOM object that will allow use of getElementByTagName with default
namespaces.

Could anyone proffer the code to return the above attribute (as string, or
ixmlattributenode)?

Many thanks in advance.

Mike
Nov 21 '05 #1
4 4104
Did you really intend to use this as an xml file? If not please post
complete xml file....but you probably should find a more on topic group.

Errors:
line 2, :
error (1102): tag uses GI for an undeclared element: Message
line 2, :
error (1203): attribute can't be checked because element is not defined:
Message
line 2, :
error (1203): attribute can't be checked because element is not defined:
Message
line 2, :
error (1203): attribute can't be checked because element is not defined:
Message
line 2, :
error (1203): attribute can't be checked because element is not defined:
Message
line 3, :
error (1102): tag uses GI for an undeclared element: id
line 3, :
error (1203): attribute can't be checked because element is not defined:
id
line 3, :
error (1150): enclosing tag undefined or lacks content model; can't
check child: id
line 4, :
error (1102): tag uses GI for an undeclared element: creationTime
line 4, :
error (1203): attribute can't be checked because element is not defined:
creationTime
line 4, :
error (1150): enclosing tag undefined or lacks content model; can't
check child: creationTime
line 5, :
error (1203): attribute can't be checked because element is not defined:
acknowledgement
line 5, :
error (1102): tag uses GI for an undeclared element: acknowledgement
line 6, :
error (1102): tag uses GI for an undeclared element: messageRef
line 7, :
error (1102): tag uses GI for an undeclared element: id
line 7, :
error (1203): attribute can't be checked because element is not defined:
id
line 7, :
error (1150): enclosing tag undefined or lacks content model; can't
check child: id
line 8, :
error (1103): end tag uses GI for an undeclared element: messageRef
line 8, :
error (1150): enclosing tag undefined or lacks content model; can't
check child: messageRef
line 9, :
error (1103): end tag uses GI for an undeclared element: acknowledgement
line 9, :
error (1150): enclosing tag undefined or lacks content model; can't
check child: acknowledgement
line 10, :
error (1103): end tag uses GI for an undeclared element: Message
line 11, :
error (402): EOF encountered; no doctype declaration found: Message

--------------------------------------------------------------------------------

Original Document:
line 2: <Message xmlns="urn:myurl-org:ns2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:myurl-org:ns2 ..\Schemas\schema.xsd"
type="Message">
line 3: <id root="7DC0FFE7-1224-4598-8F20-3B7662D416A1"/>
line 4: <creationTime value="2004"/>
line 5: <acknowledgement typeCode="AE">
line 6: <messageRef>
line 7: <id root="04074443-DE90-4FE8-9D4A-DBF9A7E81FFA"/>
line 8: </messageRef>
line 9: </acknowledgement>
line 10: </Message>
end-of-file

"Mike [MCP VB]" <www.evolvedsoftwarestudios.com> wrote in message
news:#n**************@TK2MSFTNGP11.phx.gbl:
Hi, I hope this is the right place to ask.

I have an xml file thus:

<?xml version="1.0" encoding="UTF-8"?>
<Message xmlns="urn:myurl-org:ns2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:myurl-org:ns2
..\Schemas\schema.xsd" type="Message">
<id root="7DC0FFE7-1224-4598-8F20-3B7662D416A1"/>
<creationTime value="2004"/>
<acknowledgement typeCode="AE">
<messageRef>
<id root="04074443-DE90-4FE8-9D4A-DBF9A7E81FFA"/>
</messageRef>
</acknowledgement>
</Message>

I wish to be able to parse the file such that I can return the root
attribute of the id node within messageRef.

Unfortunately, I cannot do this using msxml. getElementByTagName doesn't

work because a default namespace is provided. In fact, I cannot loop
through
the nodes either, as msxml only suggests the document has one node
<Message
/>, but no children.

I am considering swapping over from VB6 to VB.NET to accomplish this task,

as I've heard the system.xml namespace contains a revised implementation
of
the DOM object that will allow use of getElementByTagName with default
namespaces.

Could anyone proffer the code to return the above attribute (as string, or

ixmlattributenode)?

Many thanks in advance.

Mike


Nov 21 '05 #2
"scorpion53061" <ad***@nospamherekjmsolutions.com> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...
Did you really intend to use this as an xml file? If not please post
complete xml file....but you probably should find a more on topic group.


Cheers Scorpion,

There are more elements, but they aren't pertinent to this particular issue.
The validation fell over on the scoped namespace: "urn:myurl-org:ns", such
that multiple : characters are not allowed in this namespace.

Any ideas how to parse >ANY< xml file with the above default namespace
present in it? VB, VB.NET are fine. MSXML just won't have any of it...

Thanks!

Mike

Nov 21 '05 #3


Mike [MCP VB] wrote:

I have an xml file thus:

<?xml version="1.0" encoding="UTF-8"?>
<Message xmlns="urn:myurl-org:ns2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:myurl-org:ns2
..\Schemas\schema.xsd" type="Message">
<id root="7DC0FFE7-1224-4598-8F20-3B7662D416A1"/>
<creationTime value="2004"/>
<acknowledgement typeCode="AE">
<messageRef>
<id root="04074443-DE90-4FE8-9D4A-DBF9A7E81FFA"/>
</messageRef>
</acknowledgement>
</Message>

I wish to be able to parse the file such that I can return the root
attribute of the id node within messageRef.

Unfortunately, I cannot do this using msxml. getElementByTagName doesn't
work because a default namespace is provided.


It should be possible to use selectSingleNode/selectNodes with MSXML 3,
4, and 5, you just need to make sure that a namespace prefix is
associated with that default namespace e.g.
xmlDocument.setProperty "SelectionLanguage", "XPath"
xmlDocument.setProperty "SelectionNamespaces",
"xmlns:myorg='urn:myurl-org:ns2'"
then you can use that prefix e.g.
xmlDocument.selectSingleNode("/myorg:Message")

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 21 '05 #4
"Martin Honnen" <ma*******@yahoo.de> wrote in message
It should be possible to use selectSingleNode/selectNodes with MSXML 3, 4,
and 5, you just need to make sure that a namespace prefix is associated
with that default namespace e.g.
xmlDocument.setProperty "SelectionLanguage", "XPath"
xmlDocument.setProperty "SelectionNamespaces",
"xmlns:myorg='urn:myurl-org:ns2'"
then you can use that prefix e.g.
xmlDocument.selectSingleNode("/myorg:Message")


Cheers Martin. The problem was my .setProperty "SelectionNamespaces" line,
as I was not surrounding my namespace with single quotes, and therefore
msxml thought I was attempting to declare a default scoped namespace, which
apparantly - is a big no-no.

It now works regardless of the "SelectionLanguage" property... what's this
used for? Complex XPath?

However, XPath won't work in DOMDocument50.... but will in DOMDocument...
wonder why...?
--

Liddle Feesh
*fap fap fap fap*
<>< <>< <>< <>< ><>
<>< <>< <>< <>< <>< <><
Nov 21 '05 #5

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

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
0
by: Naren | last post by:
I have an XML like the one below. I am using SAX parsing and I need to get the information between the tags of the Email element. First i try to access the content and print it out and it gives...
3
by: Girish | last post by:
Hi All, I have written a component(ATL COM) that wraps Xerces C++ parser. I am firing necessary events for each of the notifications that I have handled for the Content and Error handler. The...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
5
by: PulsarSL | last post by:
Hey everyone, What function can I use to grab a .csv file from a remote webserver for use in my PHP script. I want to do some parsing and statistical analysis on it (server side). What PHP...
9
by: wardy | last post by:
I'm trying to undestand the impact of using content negotiation when rendering my Web pages to various different browsers as I would like to use the XHTML Strict DOCTYPE declaration. Reading the...
1
by: yonido | last post by:
hello, my goal is to get patterns out of email files - say "message forwarding" patterns (message forwarded from: xx to: yy subject: zz) now lets say there are tons of these patterns (by gmail,...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
0
by: taa | last post by:
Hi there I’m trying to come up with a smart way of parsing content from textboxes in C#. I have about 7-10 boxes with different content; dates, times, numbers and text that has to be parsed and...
1
by: Stuart Shay | last post by:
Hello All: I am working on parsing the Amazon Key word search webservice for the Editorial Reviews Content containing "Amazon.Com Review" in the Source element. <EditorialReviews>...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.