473,785 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LoadXML & NamespaceManage r

Hi,
Is anyone able to help me? I have the following code and when I try to
create an XPathNavigator object it keeps returning null. any cunning
ideas?

private void loadXMLDoc(Stri ng xml)
{
xmlDoc = new XmlDocument();
xmlDoc.LoadXml( xml);
namespaceManage r = new
XmlNamespaceMan ager(xmlDoc.Nam eTable);
namespaceManage r.AddNamespace( "ns1",
"urn:soj-deltascheme-com.supplierinq uiry.v1");
}

private String getFieldValue(S tring xpath)
{
return getFieldXPN(xpa th).Value;
}

private XPathNavigator getFieldXPN(Str ing xpath)
{
XPathNavigator xpn =
xmlDoc.CreateNa vigator().Selec tSingleNode(xpa th, namespaceManage r);
return xpn;
}

The XPath I am using is
"/ns1:Invoice/ns1:InvoiceDeta il/ns1:CompanyNumb er"
I have copied the xml into OxygenXML and then tested this xpath against
that within Oxygen and it works just fine. But for some reason in this
code it returns null instead of "3000".

thanks very much
cheers
Bruce

Nov 28 '06 #1
1 5070
Sorry my brain had melted, not enough sleep.
I had my namespace wrong. it should've been
"urn:soj-deltascheme-com.invoiceappr ovalv1.0"

cheers
Bruce

Nov 28 '06 #2

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

Similar topics

3
1840
by: Steve Robinson | last post by:
Just out of interest - is there an easier/quicker way to retrieve values via Xpath when namespaces are used? At the moment I seem to need a lot more lines of code to do something I thought was fairly standard? Of course I can just wrap the calls up into a helper function but was wondering if there was an easier way... XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("xs", http://mynamespace.com);
2
8691
by: Eric Zechman via .NET 247 | last post by:
I have a project in which I get xml posted via a hidden form field (data=<xml></xml>). People are entering names like Bill & Sandy Smith. this is coming over as: <NameInfo><FamilyName><FamilyNames>David &amp; Karen</FamilyNames><Surname>Adams</Surname></FamilyName></NameInfo> When I try to load this up in a XmlDocument it blows up. string xmlData = Request.Form; dom.LoadXml(xmlData); results with this: "This is an unexpected token. The...
3
6053
by: AFN | last post by:
I'm comfortable with VB.NET but new to XML. I am getting XML data from a remote machine across the internet. Sometimes my LoadXML call works fine and I parse out the data I need thereafter. But other times, LoadXML fails because it says it can't find a DTD file which is referenced in <!DOCTYPE Response SYSTEM "The_File.DTD">. I don't know what a DTD file is, but I don't have it and I'm just trying to parse the rest of the XML. ...
1
3030
by: AJ Brown | last post by:
I'm loading an XmlDocument object from a string using LoadXml. The string is a well-formed XML fragment (see example) and loads fine, however there are entities (&amp;) within attribute values. The loader parses the incoming entities and converts them to their character references automatically. How would I retain the entity? Example incoming fragment: <company name="B &amp; B Electric" />
4
3501
by: Tim Haughton | last post by:
I think I might be misunderstanding just what the LoadXml method is doing. I have 2 seemingly identical XmlDocuments, an XPath query succeeds on one of them, and fails on the other. Can anyone tell me what I'm doing wrong, and how to do it right? public void RetrieveDirectoryNumbersWithCirsAndDirs() { BillViewServiceRef.AccountRef acref = new KWPrototype.WebServices.Tests.BillViewServiceRef.AccountRef();
6
18765
by: jmgonet | last post by:
Hello everybody, I'm having troubles loading a Xml string encoded in UTF-8. If I try this code: ------------------------------ XmlDocument doc=new XmlDocument(); String s="<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><a>Schönbühl</a>"; doc.LoadXml(s); doc.Save("d:\\temp\\test.xml");
4
4416
by: Vishy | last post by:
Hi I'm trying to read xml file with namespacemanager; it seems that it adds up a namespace if there is none; How can avoid this? so <ID>00589</ID> becomes <Id xmlns=\"x-schema:#Schema1\">00589</Id> Thanks
2
2873
by: binder | last post by:
How do I eliminate an extra backslash that is appearing after LoadXML call? This issue is causing an error with Process.Start. I have a string stored in sql: c:\program files\internet explorer\iexplore.exe If I look at this data when I write the dataset to an XML file, the data is correct.
0
9481
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
10336
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
10155
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
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
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...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.