I'm trying to use XPath to get a handle on one specific node so that I can
replace it with an xml fragment I've loaded from another file.
So if I have this XML:
<issue>
<id>1</id>
<date>7/28/2006</date>
<states/>
</issue>
If "myDoc" is the preceding XML loaded into an XmlDocument object, then this
code is what I want to return the <states/node above, but it returns null
instead:
XmlNode statesNode = doc.SelectSingl eNode("//states");
I can't seem to get this XPath to return a node. Can someone help me out
here? Is there a better approach? 2 1371
You need a XMLNameSpaceMan ager before you use SelectSingleNod e
XmlNamespaceMan ager nsmgr = new XmlNamespaceMan ager(xmlDoc.Nam eTable);
nsmgr.AddNamesp ace ("IL","urn:Issu eList");
xmlNode = xmlDoc.SelectSi ngleNode("issue/states", nsmgr);
Also, if this does not return an empty string, then try including
<states></states>
instead of <states/>
Hope this helps
Ramya
Todd Price wrote:
I'm trying to use XPath to get a handle on one specific node so that I can
replace it with an xml fragment I've loaded from another file.
So if I have this XML:
<issue>
<id>1</id>
<date>7/28/2006</date>
<states/>
</issue>
If "myDoc" is the preceding XML loaded into an XmlDocument object, then this
code is what I want to return the <states/node above, but it returns null
instead:
XmlNode statesNode = doc.SelectSingl eNode("//states");
I can't seem to get this XPath to return a node. Can someone help me out
here? Is there a better approach?
That was it! I had been having complications with another issue due to
namespaces, and this cleared that up as well. Thanks!
"Ramya A" wrote:
You need a XMLNameSpaceMan ager before you use SelectSingleNod e
XmlNamespaceMan ager nsmgr = new XmlNamespaceMan ager(xmlDoc.Nam eTable);
nsmgr.AddNamesp ace ("IL","urn:Issu eList");
xmlNode = xmlDoc.SelectSi ngleNode("issue/states", nsmgr);
Also, if this does not return an empty string, then try including
<states></states>
instead of <states/>
Hope this helps
Ramya
Todd Price wrote:
I'm trying to use XPath to get a handle on one specific node so that I can
replace it with an xml fragment I've loaded from another file.
So if I have this XML:
<issue>
<id>1</id>
<date>7/28/2006</date>
<states/>
</issue>
If "myDoc" is the preceding XML loaded into an XmlDocument object, then this
code is what I want to return the <states/node above, but it returns null
instead:
XmlNode statesNode = doc.SelectSingl eNode("//states");
I can't seem to get this XPath to return a node. Can someone help me out
here? Is there a better approach?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Derek Basch |
last post by:
Hello All,
I ran into a problem while dynamically constructing XHTML documents using
minidom. If you create a script tag such as:
script_node_0 = self.doc.createElement("script")
script_node_0.setAttribute("type", "text/javascript")
script_node_0.setAttribute("src", "../test.js")
minidom renders it as:
|
by: Miguel J. Jiménez |
last post by:
Hi, I have the following node:
<node>
Some text here with lots of inside it...
</node>
and I would like it to transfrom it using XSLT to the following:
Some text<br/> here with</br> lots of</br> inside it...
Being <br/> HTML tags and not simple text like <br/>
|
by: Victor |
last post by:
While debugging my stylesheet using XMLSpy, I got a really weird result:
<xsl:if test="$match = true()"> matches even if $match is an empty node
fragment. How can this be?
--
Victor
|
by: n_o_s_p_a__m |
last post by:
My xml doc has many <title></title> and <title> in it, meaning the
nodes have no content (although some do). How can I test for this?
I tried title (doesn't work)
I tried //title (doesn't work)
I tried //title (doesn't work)
I tried //title (doesn't work)
Any suggestions welcome.
|
by: darrel |
last post by:
I have a when statement:
<xsl:when test="//pageTitle = not(string(.))">
This should find the 'pageTitle' node that has a sibling of 'linkID' that
matches the '$activeLink' parameter and see if it is empty or not.
The above returns FALSE
However, this:
| |
by: Philip Wagenaar |
last post by:
I have an XML file that will contain the data of a binary file in MIME
encoding. My application receiver the XML file with the location of the
binary file:
<REQUEST>
<IMPORT>
<DOCUMENT>
<FIELD>
<DATA>c:\myfile.dat</DATA>
</FIELD>
|
by: gregpinero |
last post by:
Hi guys,
What I'm trying to do is find all instances of an acronymn such as IBM
on a webpage and replace it with <acronym title="International Business
Machines">IBM</acronym>. However in my code below it replace the <,
and > with < and >.
Thus it replaces IBM with:
<acronym title="International Business
Machines">IBM</acronym>
|
by: esebastian |
last post by:
Hi all,
Basically i want to do get the specific node that is empty but when i
try the following i get a null node even though I know there is a node
whose AN value is null. What am i doing wrong?
"/my:MF/my:SVY/my:INSP/my:INA/my:IA/my:AN";
Thanks,
Erin
|
by: SM |
last post by:
I think that simpleXML is the best thing i've seen in PHP5. It's so
simple (d'ho!) and easy to use when
it comes to reading a simple XML file. The only thing i'm not sure how
to achieve is finding if an XML
node is empty or if the node exist or doesn't exist.
I'm searching the web, but got nothing yet. I was thinking of posting
it here.
|
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,...
|
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...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |