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

Namespace xml extract -- help

I have a file similar to this:

<Customer xmlns="http://www.localsite.com/ecommerce/2006-v01/
organization">
<ns1:Contract xmlns:ns1="http://www.localsite.com/ecommerce/2006-v01/
portfolio">
<ns1:ContractId>
<ns2:Identifier xmlns:ns2="http://www.localsite.com/ecommerce/2006-
v01/common">199</ns2:Identifier>
</ns1:ContractId>
<ns1:OrganizationId>
<ns3:Identifier xmlns:ns3="http://www.localsite.com/ecommerce/2006-
v01/common">6142</ns3:Identifier>
</ns1:OrganizationId>
</ns1:Contract>
</Customer>

How can I extract, Identifier field's data?

It seems I am not able to extract using DOM, because of Namespaces.
Any help would be appreciated.

TIA

Mar 4 '07 #1
7 2779
Mag Gam wrote:
It seems I am not able to extract using DOM, because of Namespaces.
It seems you aren't doing your homework.

DOM Level 2 and later are fully namespace-aware, if built using the
namespace-aware APIs and/or a namespace-aware parser. Look at any decent
DOM tutorial. If you don't understand namespaces, look at a good XML
tutorial as well.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 4 '07 #2
On Mar 3, 8:38 pm, Joe Kesselman <keshlam-nos...@comcast.netwrote:
Mag Gam wrote:
It seems I am not able to extract using DOM, because of Namespaces.

It seems you aren't doing your homework.

DOM Level 2 and later are fully namespace-aware, if built using the
namespace-aware APIs and/or a namespace-aware parser. Look at any decent
DOM tutorial. If you don't understand namespaces, look at a good XML
tutorial as well.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry

Thanks! As long as I am on the right track I should do well. For
Namespaces, I will use http://www.w3schools.com/xml/xml_namespaces.asp
and http://www.w3schools.com/dom/dom_examples.asp

Thanks again!

Mar 4 '07 #3
Mag Gam wrote:
Thanks! As long as I am on the right track I should do well. For
Namespaces, I will use http://www.w3schools.com/xml/xml_namespaces.asp
and http://www.w3schools.com/dom/dom_examples.asp
I did say find a *good* tutorial. Unfortunately that isn't one.

The DOM examples they show are obsolete; they use the DOM Level 1
non-namespaced create-element method, for example, which isn't
compatable with namespace-aware processing. These days you shouldn't
touch createElement(); you should only be using createElementNS(). Ditto
for other methods replaced by ...NS() versions.
Yes, I admit, this is partly the DOM WG's fault for not clearly
deprecating the old non-NS calls. We wanted to do so, but we got a huge
amount of pushback from folks who pointed out that the old calls were
still legitimate for (and ONLY for) backward-compatability with
pre-existing DOM Level 1 code. The best agreement we could get from them
was agreement that the DOM Level 2 spec should include a warning ... but
not enough people actually read the spec. Growl.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 4 '07 #4
Joe Kesselman <ke************@comcast.netwrote:
>
I did say find a *good* tutorial. Unfortunately that isn't one.
U know of >>>GOOD-GOD<<< links ?

;-)
--
Une Bévue
Mar 4 '07 #5
On Mar 4, 12:19 am, unbewusst.s...@google.com.invalid (Une Bévue)
wrote:
Joe Kesselman <keshlam-nos...@comcast.netwrote:
I did say find a *good* tutorial. Unfortunately that isn't one.

U know of >>>GOOD-GOD<<< links ?

;-)
--
Une Bévue
Yes, do you know of any links?

Mar 4 '07 #6
Mag Gam wrote:
I have a file similar to this:

<Customer xmlns="http://www.localsite.com/ecommerce/2006-v01/
organization">
<ns1:Contract xmlns:ns1="http://www.localsite.com/ecommerce/2006-v01/
portfolio">
<ns1:ContractId>
<ns2:Identifier xmlns:ns2="http://www.localsite.com/ecommerce/2006-
v01/common">199</ns2:Identifier>
</ns1:ContractId>
<ns1:OrganizationId>
<ns3:Identifier xmlns:ns3="http://www.localsite.com/ecommerce/2006-
v01/common">6142</ns3:Identifier>
</ns1:OrganizationId>
</ns1:Contract>
</Customer>

How can I extract, Identifier field's data?
Here is JavaScript that runs in W3C DOM Level 2 compliant browsers like
Mozilla or like Opera:

var identifiers =
xmlDocument.getElementsByTagNameNS('http://www.localsite.com/ecommerce/2006-v01/common',
'Identifier');
for (var i = 0, l = identifiers.length; i < l; i++) {
alert(identifiers[i].firstChild.nodeValue);
}

You could for instance load the XML document with XMLHttpRequest.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 4 '07 #7
Yes, do you know of any links?

I've been generally (not completely) pleased with the material that gets
posted at http://www.ibm.com/xml.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 4 '07 #8

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

Similar topics

2
by: Tjerk Wolterink | last post by:
IU have the following xsl root element: <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"...
1
by: Solomon Shaffer | last post by:
I have a couple of WebForms that all inherit from a custom base class (which in turn inherits from System.Web.UI.Page). I would like to locate a function in the base class that iterates through the...
7
by: carl.manaster | last post by:
Hi, Group, I know it says not to mess with the "code required for Designer support" that the IDE generates when I work with things in the layout editor, but I nevertheless find myself making...
5
by: cha | last post by:
Hi there, I wonder what the best way would be to extract some basic functions into a separate class/namespace and make them accessible for a ASP.NET-Page (aspx) and a NET-WebService (asmx). Both...
4
by: Karine Bosch | last post by:
Hi, My xml document uses different namespaces: <x:root xmlns:x="x:ns:meta/"> <element1 xmlns:adam="http://ns.alfaprint.be/"> </root> This gives problems when using an XPath query. I...
3
by: amitnicks | last post by:
Hi, I want to know that is there is a way to identify the Namespace dependency for a particular types method. Like how to know programittacly that SqlClient is in System.Data namespace? ...
1
by: Adam Eccleshall | last post by:
Hi, I'm trying to write a routine to extract results from a web service written in VS 2005 using XPath, however VS doesn't put a prefix on result namespaces by default, so in the output from a...
1
by: nightscorpion | last post by:
Hello , is there any possibility where i can extract the namespace (http://schemas.microsoft.com/project)from the xml file. ie for eg <?xml version="1.0" ?> - <Project...
5
by: Steve | last post by:
Hi all Does anybody please know a way to extract an Image from a pdf file and save it as a TIFF? I have used a scanner to scan documents which are then placed on a server, but I need to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.