|
You can:
1) Use a CData Section although even then there is the ending "]]" sequence that the data must not contain.
2) Encode the data like in Base64.
led mike
|
|
|
|
|
Hi,
I am trying to use the IF statement logic inside xml.
So came up with the line below:
The logic that I am trying to achieve is:
if there is a value for the field COMX_Field1 (i.e. if COMX_Field1 = TRUE) then show COMX_Field2, else do not show anything.
Is this correct?
Thanks
<line id="02">
<value x="1.00" formula="true">
|
|
|
|
|
=("{COMX_Field1}"="1")?"COMX_field2":""<br />
what is that supposed to be?
fmardani wrote: I am trying to use the IF statement logic inside xml.
I have no idea what that means.
led mike
|
|
|
|
|
When you say you are using the "IF statement logic inside xml", do you mean you are programming with XSLT?
|
|
|
|
|
Forum written in php is very popular. But anybody has idea about managing a forum content by xml?
|
|
|
|
|
I have an XML document in my asp.net application containing country information
eg
<Country>
<CNo>1</CNo>
<Country>Afghanistan</Country>
<Nationality>Afghan</Nationality>
<ISDCode>93</ISDCode>
<Continent>Asia</Continent>
</Country>
<Country>
<CNo>2</CNo>
<Country>Albania</Country>
<Nationality>Albanian</Nationality>
<ISDCode>355</ISDCode>
<Continent>Europe</Continent>
</Country>
<Country>
<CNo>3</CNo>
<Country>Algeria</Country>
<Nationality>Algerian</Nationality>
<ISDCode>213</ISDCode>
<Continent>Africa</Continent>
</Country>
When a country is selected from a dropdown list, I want to be able to run through the xml document and pick out the corresponding continent only. What is the best way to do this?
Thanks, Vinu<
|
|
|
|
|
XPath
replace the '?' charcter with the number for the selected country
led mike
|
|
|
|
|
Mike,
Your query won't work. Since you know the country you can find the 'Country' child node of the parent (which happens to be 'Country' too), and, then, you can access its sibling 'Continent' node:
//Country[Country='Afghanistan']/Continent
|
|
|
|
|
Thanks Mike,
Will try out the solution you have suggested. Is there anyway I can do this using XMLTextReader...
Regards,
Vinu
|
|
|
|
|
vinusk wrote: can do this using XMLTextReader...
I have not used XMLTextReader much so I do not know, but typically if you are going to query XML you use a DOM and SelectNodes(). I would normally use XmlDocument for that.
led mike
|
|
|
|
|
If you are using .NET Framework 1.1, it is XmlTextReader. If you are using .NET Framework 2.0, it is XmlReader. Anyway, you query differently with XmlTextReader/XmlReader since it uses a pull technique. However, you can get the same results but you have to do more coding. http://www.codeproject.com/useritems/XmlTextReader.asp[^]
|
|
|
|
|
George L. Jackson wrote: Your query won't work.
It worked when I ran it. Is that what you mean?
led mike
|
|
|
|
|
Here is another
XPath is pretty nice eh?
I always run these before I post them.
led mike
|
|
|
|
|
:-> My bad! Your code didn't seem correct to me. I am sorry.
|
|
|
|
|
George L. Jackson wrote: Your code didn't seem correct to me.
No sweat. It never seems right to me that's why I always run it.
led mike
|
|
|
|
|
Thanks Mike and George. I will try it out and revert back.
With warm regards,
Vinu
|
|
|
|
|
Thanks got it working.
|
|
|
|
|
Hi folks,
I bind textboxes to nodes of an XmlDocument and refer to these nodes via an xpath statement. Updating existing content is really easy this way.
My problems arise, when I try my xpath statement does not find the node in question and subsequentially I want to create it.
Say, my xpath is "/def:Version/def:Entry[lang('en')]/Title" and the second element <entry xml:lang="en"> does not exist. At first I thought, I'd split my path into pieces, ininerate it backwards, reach the first existing node and then recreate the requested structure. This could work with very easy queries, but something like "def:Entry[lang('en')]" already would require my program to "understand" that it needs to create a <entry xml:lang="en"> from the xPath lang() function.
I would end up writing a strange kind of xpath parser. And the idea isn't so good either, because I'd have to make my xpath super verbose, so that no elements (attributes!) are left out (and therefore could be created at need), which doubtlessly would decrease performance.
I stumbled across a xupdate implementation at
http://www.openvue.net/projects.php?menu=4
It's nunit testcases don't work 100% so I would have to invest some more time into this.
That's why I wanted to ask you guys, what do you think: Xupdate is the way to go for me, or do you have any other good ideas?
Thanks in advance,
Jan
|
|
|
|
|
I am confused on what you are attempting to do. I use a key to find nodes that need updating. If a key is not present, I find nodes via its parents or search for nodes that are missing certain child nodes or attributes. You may need to just determine if the structure of your XML document is right for what you are trying to do.
|
|
|
|
|
Imagine the following xml:
<foo>
<bar action="1"><element>xxx<element></bar>
<bar action="2"><element>yyy<element></bar>
<bar action="3"><element>zzz<element></bar>
</foo>
I query: /foo/bar[action='1']/element
I get "xxx" and I can update it. Good.
I query: /foo/bar[action='4']/element
Now, this node does not exist, so it should be created (and it's predecessor bar with the attribute action=4). foo exists, so nothing needs to be done for it.
Same aplies for /foo/bar[4]/element, just the attribute has to come from somewhere else (I can provide for this).
/foo/bar[5]/element should fail
This is not for a special xml file, but a generic solution, so it does not depend on any certain structure...
Does this make things a bit clearer?
-- modified at 16:53 Thursday 21st September, 2006
|
|
|
|
|
I cannot see your XML. Use "Ignore HTML tags in this message ...".
|
|
|
|
|
this should be better, now
|
|
|
|
|
I lose it right after "Now, this node does not exist, so it should be created". If you are trying to write generic code to act on any XML structure, you probably have to determine its schema beforehand.
|
|
|
|
|
Probably, looking up the schema is a good idea and I am not at all against it. The problem is, that mingling xpath with schema to create missing nodes via dom is something extremely complicated. I wouldn't even know where to start.
That's why I thought, that XUpdate would help me there, as it is an developed language for more or less this purpose. At least I am thinking it is. I just looked it up a few days ago and haven't found anything better since. But I have no idea, if XUpdate does not have any pitfalls I am not aware of, if the implementation, I found, is ok and most importantly, if there isn't some other, more straight forward way.
As for explaining my somewhat confusing (I admit) text:
I wrote a provider that allows me to update and delete nodes via xpath. That's something quite easy. Now I needed to insert nodes as well and as the xpath was something I already had in my classes, I tried to implement the insert as well via xpath. I failed at that and I am pretty sure that xpath just is not the right expression for the job.
Even though others at cp have tried something quite similar: http://www.codeproject.com/csharp/xpathstore.asp
So my examples have to be read with that bias: to use an xpath as an more or less equivalent to an sql insert statement.
I query: /foo/bar[action='4']/element
Now, this node does not exist, so it should be created (and it's predecessor bar with the attribute action=4). foo exists, so nothing needs to be done for it.
Same aplies for /foo/bar[4]/element, just the attribute has to come from somewhere else (I can provide for this).
/foo/bar[5]/element should fail (because there is no element bar[4] for it to be inserted after)
Thanks for sharing your thoughts!
Jan
|
|
|
|
|
How do i remove the last blank page?
I use page breaks in this one at the end of each page. So my last page is blank, always... How can i dump this page?
Thanks in advance
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|