Parse xml with namespace

I have this xml file, and I want to parse it and get value for each node, but I always get a nil value. Need help on this

<?xml version="1.0" encoding="UTF-8"?>
<Response instanceIdentifier="20050124" dateTime="200501241816" xmlns:cux="blablabla xmlns:cac="blibliblibli" xmlns:cbc="blebleble" xmlns="blobloblo">

procedure Tform1.Process();
       ResponseNode,ANode : IXMLNode;
       msg_version :string;

  XMLDoc.Version := '1.0';
  XMLDoc.Encoding := 'UTF-8';

  ResponseNode := XMLDoc.DocumentElement;

  msg_version :=  ResponseNode.ChildNodes.Nodes['cbc:MessageVersion'].Text;  //<==== return me nil value
  ANode := ResponseNode.ChildNodes.FindNode('OutboundMessage');
  ANode := ANode.ChildNodes.FindNode('Rate','cux'); //<== i get access violation error


Can help me on this ?
Is there any sample on internet on how to process xml with namespace using delphi's XMLDocument ?
4/21/2015 1:58:51 AM
embarcadero.delphi.xml 291 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 46

Fuandi wrote:

> I have this xml file, and I want to parse it and get value for
> each node, but I always get a nil value. Need help on this

The nodes you are looking for have different namespaces than the nodes you 
are searching, so you need to use FindNode() specifying each child's particular 
namespace, and you need to specify the actual value of the namespace, not 
the prefix used in the child node names:

procedure TForm1.Process;
  ResponseNode, ANode : IXMLNode;
  msg_version :string;
  ResponseNode := XMLDoc.DocumentElement;
  ANode := ResponseNode.ChildNodes.FindNode('MessageVersion', 'blebleble');
  if ANode <> nil then msg_version := ANode.Text;
  ANode := ResponseNode.ChildNodes.FindNode('OutboundMessage'); // OutboundMessage 
is in the same namespace as Response
  if ANode <> nil then
    ANode := ANode.ChildNodes.FindNode('Rate', 'blablabla');

Remy Lebeau (TeamB)
4/21/2015 5:07:33 PM

Similar Artilces:

XMl to XML
Hello,   I retrieved an XML from the dataset which retrieves data from the table in the database. I need to present the data  in a different structure. Is XSLT the way or are there any other options. please let me know. Thanks!! Yes XSLT is a good choice to convert xml file to other forms. You can take a look at XSLT Tutorial.Sincerely,Young Fang...

XML in, XML out
Hi All (and a happy holiday to those that will get a break), I am trying to read in an XML file of addresses. I need to remove all the address data from the file where code =~ /^000/ (there are none in the example data below). I need to reproduce that data 'as is', so I need to honour the tag structure, although the order of the tags doesn't need to be honoured. I have been trying to use XML::Simple and I had a go with XML::Smart but I haven't been able to get the results I want. My best effort is below (with XML::Simple). There are a couple of differences ...

XML::Parser XML::SimpleObject -> First XML parsing pls help
I took the example from I wanted something really simple for XML parsing that basically just reads values. But I'm stuck (again). #Here's what I'm trying to run: #!c:\perl\perl.exe use XML::Parser; use XML::SimpleObject; use strict; my $file = 'c:\perl\work\job001_card.xml'; my $parser = XML::Parser->new(ErrorContext => 2, Style => "Tree"); my $xso = XML::SimpleObject->new( $parser->parsefile($file) ); foreach my $mail ($xso->child('job_card')->children(&...

XML Parsing for large XML documents
I'm cross posting this question to perl4lib and xml4lib, hoping that someone will have a suggestion. I've created a very large (~54MB) XML document in RDF format for the purpose of importing related records into a database. Not only does the RDF document contain many thousands of individual records for electronic resources (web resources), but it also contains all of the "relationships" between those resources encoded in such a way that the document itself represents a rather large database of these resources. The relationships are multi-tiered. I've also...

------_=_NextPart_001_01C6E0D0.3E27D77A Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Hi Craig and fellow VMS Perlers, You last wrote about this Fri 3/16/2001 11:24 AM, not counting your very helpful comments on Eisner/Decuserve more recently. One of my colleagues sent me an email requesting that I make XML::XSLT=20 available on VMS. perl 5.8.6, VMS 7.3-2, DECC 7.1 latest ACRTL (version 3) on Alpha XML::XSLT (version 0.48) depends on XML::Parser (version 2.34). This depends on expat (version 2.0.0). I built expat a...

XML Creating and Parsing Very large XML Files
Hello Everyone For a long while I have used SAX for Pascal with a Delphi 6 project. it is reading and writing very large XML files (over 800MB and larger). The project has been running for years - and I recently had to upgrade to Delphi 2007 - and I discovered that SAX for Pascal has not been ported to D2007. The authors have provided full source - which I have - but now I need to get it installed into D2007. Has anyone moved the Packages over to D2007? If this is not the best way of reading and writing really large XML files anymore - any thoughts as to what is the best met...

XML template and default namespace in XML file
I have a listbox that I populate using an XML template. The specific XML file can be chosen at runtime by the user, and the datasource is set from script. This works just fine as long as the XML file has no default namespace. However, when it does, the template does not populate the list. I've not been able to find a solution to this, but it seems so obvious that someone else must have run into it. I did see a similar question posted but that was over 12 months back, and there was no reply. Anyone got any ideas? Chris <> wrote: > I have a...

HTTP post XML and parse returned XML
I am writing a web application that post xml to a webserver and then parse the returned xml. I am able to post it to the webserver, but it takes a long time to get the response from the server. I am not sure is there something wrong with my code. The following is the code that I have to do the posting and parsing the xml: Sub sendXML(ByVal xmlString As String) Dim xmlReturn As String = "" 'MsgBox(xmlString) Try Dim url As String = "" 'Dim req As WebRequest = WebRequest.Create(url)...

Xml Deserialization problem. Schema or namespaces in xml are missing.
Will try my superbest to explain it in details... There is a third-party web service, that returns XML like this:  1 <AvailabilityResult size='8'> 2 <CarAvailability> 3 <supplierType>W</supplierType> 4 <hasAirConditioning>true</hasAirConditioning> 5 <priority>10</priority> 6 <lineNumber>04</lineNumber> 7 <companyCode>AL</companyCode> 8 <companyName>ALAMO</companyName> 9 <vehicleTypeCode>SCAR</vehicleTypeCode> 10 ...

How to select Xml as Xml?
If I select Xml nodes like this from sql server; select xmlData.query('//Field[@F = "True"]') as extendedInfo from.... to loop through the items in C#? I can't cast it to a System.Xml.XmlNodeList..? You can use the XmlDocument class.  There's a Load method and a LoadXml method.  One of these should get you what you want, after which you can select nodes as you need.C# <---> VB.Net Translator mm8: If I select Xml nodes like this from sql server; select xmlData.query('//Field[@F = "True"]') as extendedInfo from.... ...

Transform XML to XML
I've been trying to transform an XML document to another XML document. The original document is very large (6megs) and the application that needs to use it only needs a fraction of the data. I'm trying to take this mother-of-all XML documents and filter out unwanted nodes. I could probably do this very easily with code by running a few XPath Queries against the document, and placing the results in a new document...however...I have an interest in learning how to do this with XSL. In the past, I've done some pretty basic XML to HTML transformation ans that worked out well. This ti...

parsing xml without namespaces
Hi, another quick question. Here's the code: DECLARE @src xmlSET @src = '<MyRoot xmlns:i="" xmlns="urn:Some.Urn.Goes.Here"> <Elements>3404, 3405</Elements></MyRoot>';WITH xmlnamespaces(DEFAULT 'urn:Some.Urn.Goes.Here')SELECT CAST( @src.query('MyRoot/*') AS nvarchar(MAX) )It gives the output as<p1:Elements xmlns:p1="urn:Some.Urn.Goes.Here">3404, 3405</p1:Elements>What do I need to strip out the namespace and <Elements> tag and get "3404, 3405"...

sort xml in xml
Hi, How I can sort xml file in xml with VB.NetThanks,<?xml version="1.0" encoding="ISO-8859-1" ?>  <Liste>   <Form Famille="Administration" idXhtml="" idOffice="31574" nom="ADM" desc="" />   <Form Famille="Admini" idXhtml="" idOffice="31708" nom="ADM- 54 (2000)" desc="" />   <Form Famille="communication" idXhtml="" idOffice="31709" nom="ADM- 133 (2000)" desc="" />   <Form Famille="Admini" idXhtml="" idOffice="31710" nom="ADM- 9 (2000)" desc="" />   <Form Famille="Admini" idXhtml="" idOffice="31711" no...

XML to XML transform
Hi all, I have an XML file in which I just want to change a couple of values.  So, the end result is a new file with exactly the same XML structure.  I am new to XML and XSLT, so I thought I'd start off with something simple; I created an xsl file that would just copy the source directly across without modifying the values (I can do this later, once I have the first bit figured) - <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:con=""><xsl:template match="/"...

Web resources about - Parse xml with namespace - embarcadero.delphi.xml

Namespace - Wikipedia, the free encyclopedia
Namespaces provide a level of indirection to specific identifiers, thus making it possible to distinguish between identifiers with the same exact ...

Wikipedia:Help namespace - Wikipedia, the free encyclopedia
The Help namespace is a namespace consisting of Wikipedia pages whose titles begin with the prefix Help: , such as Help:Link . These pages contain ...

ICANN seeks to tackle DNS namespace collision risks
As the number of top-level domains undergoes explosive growth, the Internet Corporation for Assigned Names and Numbers (ICANN) is studying ways ...

OS X Lion: Guidelines for connecting to a DFS namespace via SMB
Ensure that the following guidelines are followed when connecting to a DFS namespace via SMB in OS X Lion.

Facebook's Namespace Land Grab? Or Maybe…It's Just Useful
Much buzz over the past few days about Facebook’s plans to let folks (and, ahem, brands) claim their namespaces on Facebook. IE, Starting this ...

Global Namespace for People (Part 3)
I ended yesterday’s post by saying that I would write about potential solutions to the global namespace problem for people (parts 1 and 2). So ...

Netflix namespace problem · Issue #34 · balloob/pychromecast · GitHub
pychromecast - Library for Python 2 and 3 to communicate with the Google Chromecast.

Adding Namespaces To Ruby
... about how close I can get Ruby to look like Clojure in size and style. Recently, what has bothered me most has been how you define a namespace ...

PHP 5.6 features built-in debugger, better namespace support
PHP, the venerable scripting language for server-side Web development, has been upgraded in a point release highlighted by a new debugger.

#include<bits/stdc++.h> using namespace std; int n, x, y; int main() { fo -
PASTEBIN - #1 paste tool since 2002 create new paste tools api archive faq PASTEBIN create new paste trending pastes sign up login my alerts ...

Resources last updated: 1/17/2016 5:43:38 PM