473,788 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Namespace xml extract -- help

I have a file similar to this:

<Customer xmlns="http://www.localsite.c om/ecommerce/2006-v01/
organization">
<ns1:Contract xmlns:ns1="http ://www.localsite.c om/ecommerce/2006-v01/
portfolio">
<ns1:ContractId >
<ns2:Identifi er xmlns:ns2="http ://www.localsite.c om/ecommerce/2006-
v01/common">199</ns2:Identifier>
</ns1:ContractId>
<ns1:Organizati onId>
<ns3:Identifi er xmlns:ns3="http ://www.localsite.c om/ecommerce/2006-
v01/common">6142</ns3:Identifier>
</ns1:Organizatio nId>
</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 2794
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.netwro te:
>
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.inva lid (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.c om/ecommerce/2006-v01/
organization">
<ns1:Contract xmlns:ns1="http ://www.localsite.c om/ecommerce/2006-v01/
portfolio">
<ns1:ContractId >
<ns2:Identifi er xmlns:ns2="http ://www.localsite.c om/ecommerce/2006-
v01/common">199</ns2:Identifier>
</ns1:ContractId>
<ns1:Organizati onId>
<ns3:Identifi er xmlns:ns3="http ://www.localsite.c om/ecommerce/2006-
v01/common">6142</ns3:Identifier>
</ns1:Organizatio nId>
</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.get ElementsByTagNa meNS('http://www.localsite.c om/ecommerce/2006-v01/common',
'Identifier');
for (var i = 0, l = identifiers.len gth; i < l; i++) {
alert(identifie rs[i].firstChild.nod eValue);
}

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
4932
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" xmlns:page="http://www.wolterinkwebdesign.com/xml/page" xmlns:xc="http://www.wolterinkwebdesign.com/xml/xcontent"> Well how do i select the xhtml namespace with xpath
1
1599
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 control collection of the child page, looks at the type (looking for System.Web.UI.WebControls.Label type), and pulls out the full namespace and ID for that control (then goes out to a resouce file and sets the text of the control for the...
7
1583
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 changes along these lines: this.bMagnifier = new System.Windows.Forms.Button(); this.bMagnet.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
5
3378
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 files are written in VB.NET Is there a detailled description somewhere existing in the Internet of how to do the extraction of basic funtions into a separate class/namespace and use this new class/namespace then within a ASP.NET
4
2276
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 already created 2 namespace managers
3
1342
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? Thanks in advance. Nicks
1
2270
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 service such as <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body>
1
2001
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 xmlns="http://schemas.microsoft.com/project"> <Name>test.xml</Name> <Title>MS-Project2000- Kalender</Title> <CreationDate>1998-09-10T13:43:00</CreationDate>
5
5765
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 extract the image of the document (just the first page if there are multiple pages) and save it as a TIFF so I can then use the Tesseract OCR to get the text in the image.
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10118
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8995
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.