f



extracting text from an XML node

Hi,

suppose i get the simple xml sample:
<foo>
  1
  <bar>2</bar>
  3
</foo>

Now suppose i want to extract all the text of only the 'foo' node, ie
expected result is '1 3'.
I tried both

  <xsl:template match="foo">
    <xsl:value-of select="text()" />
  </xsl:template>

and

  <xsl:template match="foo">
    <xsl:value-of select="." />
  </xsl:template>

but the former lead to '1' and the latter to '1 2 3' (using xsltproc &
firefox).
What did i missed ?

thanks,

-Nicolas
0
11/29/2007 9:00:50 PM
comp.text.xml 8781 articles. 0 followers. Post Follow

10 Replies
639 Views

Similar Articles

[PageSpeed] 42

nicolas.edel@gmail.com wrote:
> Now suppose i want to extract all the text of only the 'foo' node

That isn't a built-in concept; you have to recast it as "all the text 
nodes which are immediate children of the 'foo' node". (The built-in 
text value of an element, as you discovered, is the value of all text 
contained in it, directly or indirectly). Note too that the whitespace 
(line breaks and indentation) will be part of the the text nodes unless 
you explicitly strip that away.

     <xsl:value-of select="text()" />

didn't work because value-of returns the contents of only the first 
matching node. This is one case where xsl:for-each is appropriate, to 
explicitly iterate through the text children.

-- 
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
0
11/29/2007 11:34:08 PM
On Nov 30, 12:34 am, Joseph Kesselman <keshlam-nos...@comcast.net>
wrote:
> Note too that the whitespace
> (line breaks and indentation) will be part of the the text nodes unless
> you explicitly strip that away.

yes, but i didn't focused on it since this was not the main problem

>
>      <xsl:value-of select="text()" />
>
> didn't work because value-of returns the contents of only the first
> matching node. This is one case where xsl:for-each is appropriate, to
> explicitly iterate through the text children.
>

Ok, i misunderstood the 'text()' semantic. And indeed
    <xsl:for-each select="child::text()">
      <xsl:value-of select="."/>
    </xsl:for-each>
does the job.

Thanks a lot.

-Nicolas
0
11/30/2007 8:10:11 AM
On Nov 30, 9:10 am, nicolas.e...@gmail.com wrote:
>     <xsl:for-each select="child::text()">
>       <xsl:value-of select="."/>
>     </xsl:for-each>
> does the job.

Well, xsltproc and firefox do not behave the sameway.

foo.xml:
 <foo>
  1
  <bar>2</bar>
  3
</foo>

foo.xsl:
  <xsl:template match="foo">
     <xsl:for-each select="child::text()">
       <xsl:value-of select="."/>
     </xsl:for-each>
    <xsl:value-of select="." />
  </xsl:template>

Results:
   xsltproc => '1 3'
   firefox   => '1 2 3'

Which one is wrong ?

-Nicolas
0
11/30/2007 9:30:02 AM
nicolas.edel@gmail.com <nicolas.edel@gmail.com> wrote in
<b086323a-da6a-4afb-a86b-748a093a373c@j44g2000hsj.googlegroups.com>:
> On Nov 30, 9:10 am, nicolas.e...@gmail.com wrote:
>>     <xsl:for-each select="child::text()">
>>       <xsl:value-of select="."/>
>>     </xsl:for-each>
>> does the job.
> 
>   <xsl:template match="foo">
>      <xsl:for-each select="child::text()">
>        <xsl:value-of select="."/>
>      </xsl:for-each>

To blow my anti-xsl:for-each trumpet one more time,

  <xsl:apply-templates select="text()"/>

....should do the same, unless you've defined a template of
your own that would match those text nodes. The default
template for text nodes is:

  <xsl:template match="text()|@*">
    <xsl:value-of select="."/>
  </xsl:template>

>     <xsl:value-of select="." />
>   </xsl:template>

That's not a complete example, and it seems you've left some
of the chunks you used in the debugging in it.

> Results:
>    xsltproc => '1 3'
>    firefox   => '1 2 3'
> 
> Which one is wrong ?

Please post a minimal complete example that demonstrates the
problem, so that we can check ourselves. I'm unaware of any
differences between libxslt and TranforMiiX that could
cause the effect described, and, frankly, I doubt the
problem lies with the transformation engines you're using.

-- 
....also, I submit that we all must honourably commit seppuku
right now rather than serve the Dark Side by producing the
HTML 5 spec.
0
p.lepin1 (393)
11/30/2007 10:07:05 AM
On Nov 30, 11:07 am, Pavel Lepin <p.le...@ctncorp.com> wrote:
> >   <xsl:template match="foo">
> >      <xsl:for-each select="child::text()">
> >        <xsl:value-of select="."/>
> >      </xsl:for-each>
>
> To blow my anti-xsl:for-each trumpet one more time,
>
>   <xsl:apply-templates select="text()"/>
>

Oh, I didn't know the '<xsl:value-of select="."/>' may be implicit.

> ...should do the same, unless you've defined a template of
> your own that would match those text nodes. The default
> template for text nodes is:
>
>   <xsl:template match="text()|@*">
>     <xsl:value-of select="."/>
>   </xsl:template>
>

Wouldn't this would copy the attributes value too ?

> Please post a minimal complete example that demonstrates the
> problem, so that we can check ourselves. I'm unaware of any
> differences between libxslt and TranforMiiX that could
> cause the effect described, and, frankly, I doubt the
> problem lies with the transformation engines you're using.
>

foo.xml
----------------- 8< -----------------------
<?xml version="1.0"?>
<?xml-stylesheet href='foo.xsl'?>
<foo>
  1  <bar>2</bar>  3
</foo>
----------------- 8< -----------------------

foo.xsl (according to your advice)
----------------- 8< -----------------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:template match="foo">
    <xsl:apply-templates select='text()'/>
  </xsl:template>
</xsl:stylesheet>
----------------- 8< -----------------------

Not taking output layout into account , xsltproc produces '1 3' while
firefox still produces '1 2 3'

-Nicolas
0
11/30/2007 10:35:14 AM
On Nov 30, 11:35 am, nicolas.e...@gmail.com wrote:
> > To blow my anti-xsl:for-each trumpet one more time,
>
> >   <xsl:apply-templates select="text()"/>
>
> Oh, I didn't know the '<xsl:value-of select="."/>' may be implicit.

Now I understand http://www.w3.org/TR/xslt#built-in-rule ;)

-Nicolas
0
11/30/2007 10:39:06 AM
nicolas.edel@gmail.com <nicolas.edel@gmail.com> wrote in
<6d619ec9-0130-40af-a895-56cd5b955425@y5g2000hsf.googlegroups.com>:
> On Nov 30, 11:07 am, Pavel Lepin <p.le...@ctncorp.com>
> wrote:
>> >   <xsl:template match="foo">
>> >      <xsl:for-each select="child::text()">
>> >        <xsl:value-of select="."/>
>> >      </xsl:for-each>
>>
>> To blow my anti-xsl:for-each trumpet one more time,
>>
>>   <xsl:apply-templates select="text()"/>
>>
>> ...should do the same, unless you've defined a template
>> of your own that would match those text nodes. The
>> default template for text nodes is:
>>
>>   <xsl:template match="text()|@*">
>>     <xsl:value-of select="."/>
>>   </xsl:template>
> 
> Wouldn't this would copy the attributes value too ?

It would, in case you applied templates to attributes
somewhere without specifying another template that would
match said attributes.

> <?xml version="1.0"?>
> <?xml-stylesheet href='foo.xsl'?>

This must be:

  <?xml-stylesheet href="foo.xsl" type="text/xsl"?>

(I'm not sure whether it's mandated somewhere in the specs,
and cannot spare any time to look it up right now, but the
fact is that Firefox won't grok it otherwise.)

> <foo>
>   1  <bar>2</bar>  3
> </foo>
> 
> <?xml version="1.0"?>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">

You'll need:

  <xsl:output method="text"/>

here. Otherwise Firefox will expect the transformation to
produce an XML document. Which it doesn't do.

>   <xsl:template match="foo">
>     <xsl:apply-templates select='text()'/>
>   </xsl:template>
> </xsl:stylesheet>
> 
> Not taking output layout into account , xsltproc produces
> '1 3' while firefox still produces '1 2 3'

Firefox doesn't actually run the transformation because it
cannot parse the PI you wrote. If you fix the PI without
changing the output method, it will simply display an empty
document, since the transformation doesn't actually produce
an XML document. If you fix both of those problems, Firefox
will display the expected resulting document.

-- 
....also, I submit that we all must honourably commit seppuku
right now rather than serve the Dark Side by producing the
HTML 5 spec.
0
p.lepin1 (393)
11/30/2007 11:38:19 AM
On Nov 30, 12:38 pm, Pavel Lepin <p.le...@ctncorp.com> wrote:
>
> Firefox doesn't actually run the transformation because it
> cannot parse the PI you wrote. If you fix the PI without
> changing the output method, it will simply display an empty
> document, since the transformation doesn't actually produce
> an XML document. If you fix both of those problems, Firefox
> will display the expected resulting document.

Indeed.
Many thanks for your precious help.

-Nicolas
0
11/30/2007 12:59:00 PM
>>  <xsl:apply-templates select="text()"/>
>>...should do the same, unless you've defined a template of
>>your own that would match those text nodes.

Granted.

-- 
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
0
11/30/2007 4:43:43 PM
<nicolas.edel@gmail.com> wrote in message 
news:e9e64863-aafb-43ed-9d0d-f2c187ea0b36@y43g2000hsy.googlegroups.com...
> Hi,
>
> suppose i get the simple xml sample:
> <foo>
>  1
>  <bar>2</bar>
>  3
> </foo>
>
> Now suppose i want to extract all the text of only the 'foo' node, ie
> expected result is '1 3'.
> I tried both
>
>  <xsl:template match="foo">
>    <xsl:value-of select="text()" />
>  </xsl:template>
>
> and
>
>  <xsl:template match="foo">
>    <xsl:value-of select="." />
>  </xsl:template>
>
> but the former lead to '1' and the latter to '1 2 3' (using xsltproc &
> firefox).
> What did i missed ?


This is pretty simple.
Use:

  <xsl:template match="foo/text()">
    <xsl:value-of select='concat(.,' ')'/>
  </xsl:template>


Cheers,
Dimitre Novatchev. 


0
dimitren1 (155)
12/1/2007 5:53:47 AM
Reply:

Similar Artilces:

XML DOM: XML/XHTML inside a text node
In my program, I get input from the user and insert it into an XHTML document. Sometimes, this input will contain XHTML, but since I'm inserting it as a text node, xml.dom.minidom escapes the angle brackets ('<' becomes '&lt;', '>' becomes '&gt;'). I want to be able to override this behavior cleanly. I know I could pipe the input through a SAX parser and create nodes to insert into the tree, but that seems kind of messy. Is there a better way? Thanks. On Thu, 2 Nov 2005 noahlt@gmail.com wrote: > In my program, I get input from the us...

xml wrongly views as text extracted from the xml tags
we have a java framework, where we feed a request xml. this request xml is forwarded through the framework, tomcat and axis, for the backend processing, and the processing results are again received by the internet explorer, after they are transformed with an xslt by the framework. now the problem that we are facing is like - the explorer extracts the text inside all xml tags of the response xml and shows it as simple text. but, if you view the source of the 'text', it will show it all as well-formed xml. moreover, if you save the source as an xml file, and again open it through internet explorer, it will show the xml in proper way. i have tried using firefox, processing with xml spy, but with same results... has somebody experienced similar problem before??? i wonder what can be wrong in this case, and would be thankful for any pointers as to what can be the cause and solution to this. Thanks in advance, Shreyas Hi all, Finally i got what was the problem. it was because the response xml contained a <Title> </Title> tag in it. and dont know why/how, but IE was treating it as an HTML tag. i noticed that the browser window title was indeed "Mr" which is the text enclosed by the Title element. one more weird thing i noticed was that if i moved the <xsl:apply-templates> line for the tag downwords after one more template application, it was showing the xml properly alongwith the <Title> element, and not treating it as an HTML tag...

file command: "XML document text" vs "XML document text"
I've just used the file command on four files of RDF-XML with the following output: augtfidf.rdf: XML document text kyoto.rdf: XML document text stuff.rdf: XML document text tfidf.rdf: XML document text What does it mean that one of them has an extra space between "XML" and "document"? -- The kid's a hot prospect. He's got a good head for merchandising, an agent who can take you downtown and one of the best urine samples I've seen in a long time. [Dead Kennedys t-shirt] On 16.10.2012 16:06, Adam Funk wrote: > I've just used the file command on four files of RDF-XML with the > following output: > > augtfidf.rdf: XML document text > kyoto.rdf: XML document text > stuff.rdf: XML document text > tfidf.rdf: XML document text > > What does it mean that one of them has an extra space between "XML" > and "document"? Hard to tell without further information. What does file *.rdf | od -c show you? Janis Janis Papanagnou wrote: > On 16.10.2012 16:06, Adam Funk wrote: >> I've just used the file command on four files of RDF-XML with the >> following output: >> >> augtfidf.rdf: XML document text >> kyoto.rdf: XML document text >> stuff.rdf: XML document text >> tfidf.rdf: XML document text >> >> What does it mean that one ...

Non-XML tagged value text to XML
I would like to use XSLT to translate some tagged value text to XML elements like this: Input Doc: <data>x=1.234 y=ABC z="Hello World"</data> Output Doc: <x>1.234</value> <y>ABC</y> <z>&quot;Hello World&quot;</z> Is XSLT up to the task? What would it look like? Most of the XSLT string processing code I've seen looks very verbose - can't be too efficient. mikea_59 wrote: > I would like to use XSLT to translate some tagged value text to XML > elements like this: > > Input Doc: > > <data>x=1.234 y=ABC z="Hello World"</data> > > Output Doc: > > <x>1.234</value> > <y>ABC</y> > <z>&quot;Hello World&quot;</z> > > Is XSLT up to the task? What would it look like? Most of the XSLT > string processing code I've seen looks very verbose - can't be too > efficient. Using XSLT 2.0 you can do that with regular expression matching as follows: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" encoding="UTF-8" indent="yes" /> <xsl:template match="/"> <results> <xsl:apply-templates /> </results> </xsl:template> <xsl:template match="data"...

XML Schema for Node with attribute and text
I've tried to find how to write a schema for this type of node everywhere. <Param name="FirstParam">ABCD</Param> How do i arrange a complex type that contains an attribute and a text. This : <xs:complexType name="Param"> <xs:attribute name="name" /> </xs:complexType> Result as : <invalid char="13" code="cvc-complex-type.1.2" line="3086" resource="file:///C:/WINNT/Profiles/svaillan/Desktop/XML Schema/test.xml">element Param must be empty but is not</invalid> This : <xs:complexType name="Param"> <xs:all> <xs:element name="text" type="xs:string" /> </xs:all> <xs:attribute name="name" /> </xs:complexType> Result as : <invalid char="13" code="cvc-complex-type.1.2.3" line="3086" resource="file:///C:/WINNT/Profiles/svaillan/Desktop/XML Schema/test.xml">text not allowed: |ABCD|</invalid> I just dont know where to add the unnamed <xs:element ... > tag. Anyone can help me figure this out? Thx In article <de3c2ad2.0311281339.e74b69b@posting.google.com>, Simon Vaillancourt <svaillancourt@mediagrif.com> wrote: % I've tried to find how to write a schema for this type of node % everywhere. % % <Param name="FirstParam">ABCD</Param> % % How do...

XML to XML
I have a gnucash file that I'm trying to transform into an identical XML file without the invoices. I've been at this for a while now. The gnucash file is in XML and the element I'm looking into is: <gnc:transaction> I want to ignore those that contain <slot:key>gncInvoice</slot:key> which is a child of slot which is a child of slots which is a child of transactions. Any help you're willing to provide would be greatly appreciated. Thanks. Classic application for XSLT. Start with the identity transformation, then add a template which matches the ones you want to treat specially and yields no output. From your description that would be match="gnc:transaction[transactions/slots/slot/slot:key='gncInvoice']" with the namespaces declared appropriately in the stylesheet. (That looks like a somewhat unlikely markup design to me, but since I haven't played with gnucash at all I'm taking your word for it.) -- () ASCII Ribbon Campaign | Joe Kesselman /\ Stamp out HTML e-mail! | System architexture and kinetic poetry Actually, from the Relax-NG schema for gnucash, it looks like it should be more like "gnc:transaction[trn:slots/slot/slot:key='gncInvoice']" with gnc:, trn:, and slot: all bound to the appropriate namespace URIs. The fact that some of their elements -- eg <slot> -- aren't in any namespace is probably left over from a pre-namespaces initial design, as is their now-brok...

text + text
What is "text + text" supposed to do right now? It doesn't seem very useful to me. What about making "text + text" as an equivalent for "text || text"? Most strongly-typed programming languages do this. And MS SQL Server too, I think (CMIIW). -- dave ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org Am Freitag, 8. Oktober 2004 12:57 schrieb David Garamond: > What is "text + text" supposed to do right now? Nothing. > What about making "text + text" as an equivalent for "text > || text"? Most strongly-typed programming languages do this. And MS SQL > Server too, I think (CMIIW). What would this gain except for bloat? It's not like SQL is utterly compatible with any programming language; users will still have to learn all the operators anyway. -- Peter Eisentraut http://developer.postgresql.org/~petere/ ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match Peter Eisentraut wrote: >>What is "text + text" supposed to do right now? > > Nothing. Then are these bugs? (7.4.5 and 8.0.0beta1 give same results). Frankly, the current behaviour is quite strange to me. ------------------ =...

To XML or not to XML?
Ok, it has been a while since I've needed to make an involved web page. Coming back on the scene now is a bit confusing, what with all the cool stuff to use like XML, PHP, MySQL, etc... So here is my question. I'm in search of a good dynamic way to generate web pages which separates content from presentation. I am seeking to create a web site that, to put it succinctly, has a list of users and sets of information corresponding to each user. I am familiar with how to do this using PHP, MySQL, and regular old HTML. I maintain the user database in MySQL and dynamically present it and th...

XML or not XML?
I am developing a simple MySQL database editor, and am looking into creating an PHP/AJAX app as the GUI. A lot of this in new ground, and much more is dusting off things I haven't used in a while. My question though involves whether or nor to employ XML. I did some XML a few years back, but don't typically bother anymore. As I see it XML is great when I need to have an app with a standard data presentation that other developers can easily interface. I.E. like a bank statement that may feed a variety of applications developed by a variety of clients. However, if I am develo...

editor for editing xml text nodes
We have xml documents which contain text imbedded as text content in some xml structures. These documents need to be translated by human translators from English into, for example, Chinese. We would like the translator to use an editor which shows him only the text content of the xml document, or gives him only editing access to the text content. The translator should be unable to touch or modify the xml tags, so that it is guaranteed that the xml-tags are unchanged when the translator returns the translated document. The translator simply replaces all English text accessible to him into Chinese text. Does anyone know an xml editing tool which has this feature, of allowing only modification to the text node content? Alois Zreindl wrote: > We have xml documents which contain text imbedded as text content in > some xml structures. > > These documents need to be translated by human translators from English > into, for example, Chinese. > > We would like the translator to use an editor which shows him only the > text content of the xml document, or gives him only editing access to > the text content. I am working on exactly this right now. It leaves the elements in element content inviolable, but allows element markup in mixed content (the only thing a translator should be touching). Please contact me by email to discuss this further. > The translator should be unable to touch or modify the xml tags, so that > it is guara...

text-text
Wondering how what I input to my UTF-8 terminal gets passed along through my patched [1] trn ... Cyrillic: А Б В Г Д Е Ж З И Й К Л М Н О П а б в г д е ж з и й к л м н о п IPA: ᴀ ᴁ ᴂ ᴃ ᴄ ᴅ ᴆ ᴇ ᴈ ᴉ ᴊ ᴋ ᴌ ᴍ ᴎ ᴏ ɀ Ɂ ɂ Ƀ Ʉ Ʌ Ɇ ɇ Ɉ ɉ Ɋ ɋ Ɍ ɍ Ɏ ɏ [1] https://groups.google.com/d/msg/comp.sys.raspberry-pi/7Z37Hdrm0DM/6aqD-reXFzAJ ...

converting a document node and children into xml text
is there a way in javascript to convert a DOM node (and it's children) into an XML text. i'd like to save the text file somewhere and then later parse it to re-create the tree. thx. jman, google grouper, wrote: > is there a way in javascript to convert a DOM node (and it's children) > into an XML text. Yes. Traverse the DOM node subtree and output XML accordingly. > i'd like to save the text file somewhere and then later parse it > to re-create the tree. Why? jman wrote: > is there a way in javascript to convert a DOM node (and it's children) > ...

How to retrieve XML CDATA text contents by org.xml.sax.ext.DefaultHandler2?
For example I have a XML tag <script> <![CDATA[ My script is here ]]> </script> I am using org.xml.sax.ext.DefaultHandler2 to parse my XML file. How do I retrieve my script contents? What shall I do in these two methods? @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (qName.equals("script")) { // How to retrieve my script contents? } } @Override public void endElement(String uri, String localName, String qName) throws SAXException { if (qName.equals("script")) { ...

Adding and updating new tDOM XML text nodes
Hi guys, Some code: package require tdom # Read in data in the xml variable. set dom [dom parse -keepEmpties \ "<BASE>\n<al>\n<Cats>9 lives</Cats>\n<Canaries/>\n</al>\n</BASE>"] set doc [$dom documentElement] # Add a missing node. set node [$doc selectNodes /BASE/al] $node appendXML "<Dogs></Dogs>" # Update an existing node. set node [$doc selectNodes /BASE/al/Cats/text()] $node nodeValue "Great swingers" # Output doc to show Dogs got added and Cats changed. puts [$doc asXML] # Try to update the node with some data. set node [$doc selectNodes /BASE/al/Dogs/text()] $node nodeValue "Go Woof" Output: <BASE> <al> <Cats>Great swingers</Cats> <Canaries/> <Dogs/> </al> </BASE> invalid command name "" while executing "$node nodeValue "Go Woof"" (file "t" line 15) Platform: ActiveTCL 8.4.13.0.261555. Strangeness: I can add the new node to the XML (and it's even reformatted) for it to be called in when doing the $doc asXML, but, I can't update a newly added node. Anyone have any suggestions? In article <slrneh8g2p.irn.flavp+hfrarg@sparrow.autons.net.au>, Synic <flavp+hfrarg@nhgbaf.arg.nh> wrote: >Some code: > > package require tdom > # Read in data in the xml variable....

extract plain-text from xml-file / remove all tags
For feeding the content of an xml-file to a search-indexer I need to remove all tags and extract the plaintext out of a xml-file. I use the null-xls-stylesheet <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> </xsl:stylesheet> to remove all tags. Problem now is that, while it actually works, I found out that removing all tags is not exactely what I want, cause I ended up with all content in one string without any whitespace in between. So actually what i want is to replace all tags with a space. I use linux/xsltproc/perl and I am definitely no master of xml. I rarely used it until now and while I do quite fine in perl, I cannot master this simple xml-problem on my own thnx for any help peter In article <8fe49$4740aaa6$557f11d9$2752@news.inode.at>, peter pilsl <pilsl@goldfisch.at> wrote: >Problem now is that, while it actually works, I found out that removing >all tags is not exactely what I want, cause I ended up with all content >in one string without any whitespace in between. So actually what i want >is to replace all tags with a space. As usual, you should start with an identity stylesheet: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:cop...

Should the webserver add "Content-Type: text/xml header" to the requested XML file?
I've been informed that a webserver sending a XML file is supposed to add "Content-Type: text/xml header". I'm not questioning that infromation but i'm unsure what was ment by it. The XML i get on my screen when i type in the url to it looks as follows. <?xml version="1.0" encoding="UTF-8"?> <tag-uno>uno</tag-uno> <tag-duo>duo</tag-duo> I can't see any line containing "text/xml" but perhaps it's not supposed to show in the requested file. Please advise. -- Regards Konrad Viltersten ---------------...

xml file in JTree: hide text nodes with only one character
Hello, I am working on an app that will display an xml file in a JTree. So far, element and text nodes are both correctly recognized. In fact, the recognition is too good. THe xml file contains some line feeds which are interpreted as text nodes are consequently displayed in the tree as well. I tried to hide these node by using the following tree cell renderer: class XmlTreeCellRenderer extends JLabel implements TreeCellRenderer {public Component getTreeCellRendererComponent (JTree tree, Object node, boolean selected, boolean expanded, boolean isLeaf, int row, boolean hasFocus) {//* node is ...

need a help to create XML node with text and sub child.
Hi folks I need a help to create XML node with text and sub child. -------------------------------------------------------- I want to create "ADDR" node with text and child node. (First child node and then text.) <?xml version="1.0" encoding="UTF-8" ?> - <ROOT> - <NODE> <child-1 attr="attr-value">This is child text</child-1> - <ADDR> <postcode>12345</postcode> Address information </ADDR> </NODE> </ROOT> -------------------------------------------------------- I can create "ADDR" node with text and child node. But first text and then child node. I can not change the location of text and child node of "ADDR" node. <?xml version="1.0" encoding="UTF-8" ?> - <ROOT> - <NODE> <child-1 attr="attr-value">This is child text</child-1> - <ADDR> Address information <postcode>12345</postcode> </ADDR> </NODE> </ROOT> ------------------------------------------------------------------------------------ This is code which I did (ASP) ------------------------------------------------------------------------------------ Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM") If (xmlDoc.childNodes.length = 0) Then Set objProcInstr = xmlDoc.createProcessingInstruction("xml", "version=""1.0"" encoding...

embedding xml in xml as non-xml :)
Hi all, I have an application that logs in xml. Assume <xmlLog></xmlLog>. In this element the app logs anything it gets from foreign hosts. Now if the host sends xml data, the structure of the document changes. ie. <xmlLog><somTag></somTag></xmlLog>. This will cause problems with my log reader, because it assumes that <xmlLog/> contains non-xml data. My question is, is there a way to treat the data in the <xmlLog/> element as non xml data. Something I can do that would treat anything this element contains as a literal? Any help or suggestions would be greatly appreciated. Regards, Mark Mark Van Orman <mark@icsaccess.com> wrote: > Hi all, > > I have an application that logs in xml. > > Assume <xmlLog></xmlLog>. In this element the app logs > anything it gets from foreign hosts. Now if the host sends xml > data, the structure of the document changes. ie. > <xmlLog><somTag></somTag></xmlLog>. This will cause problems > with my log reader, because it assumes that <xmlLog/> contains > non-xml data. > > My question is, is there a way to treat the data in the > <xmlLog/> element as non xml data. Something I can do that > would treat anything this element contains as a literal? > > Any help or suggestions would be greatly ap...

how to Update/insert an xml element's text----> (<element> text</element>)
hello friends, how can we update or insert into an xml Element. For example : ------------------- <?xml version="1.0"> <request> <main> <name>ISO8856</name> </main> </request> here when we run a java class file it should replace "ISO8856"with "ISO9001". Any Assistance or example. thanQ in adv. Ajay HANM wrote: > <?xml version="1.0"> > <request> > <main> > <name>ISO8856</name> > </main> > </request> > > here when we run a java class file it should replace "ISO8856"with > "ISO9001". Any Assistance or example. If you use the W3C DOM Level 3 Core as implemented in Java 1.5 and later then you can select the 'name' element and set its textContent e.g. Element name = (Element)xmlDocument.getElementsByTagName("name").item(0); name.setTextContent("ISO09001"); If you use DOM Level 2 Core (as implemente in Java 1.4) then you need to access the firstChild and set its nodeValue Element name = (Element)xmlDocument.getElementsByTagName("name").item(0); name.getFirstChild().setNodeValue("ISO09001"); -- Martin Honnen http://JavaScript.FAQTs.com/ Many good tutorials/articles exist on the web (and some bad ones, alas). I usually point people to http://www.ibm.com/xml -- Joe K...

How to extract the plain text from a rich text ?
Hi everybody ! I can't find how to get a wxstring containing the plain text from a wxstring containing rich text. Does anybody how to do that ? Thanks ! ...

How IE's and Firefox's XML DOM parsers deal with whitespace text nodes
Can someone please explain this section of this tutorial me? http://www.w3schools.com/dom/dom_mozilla_vs_ie.asp The relevant text I do not understand is: "Internet Explorer, when using node.childNodes[], will NOT contain these white-space nodes. In Mozilla, those nodes will be in the array." and "Internet Explorer will skip the white-space text nodes that are generated between nodes (e.g. new line characters), while Mozilla will not. So, in the example above, Mozilla browsers will alert 9 child nodes, while Internet Explorer will alert 4." I checked the said file: http://www.w3schools.com/dom/books.xml In both, Firefox 2.0 as well as IE 6.0, it had only 4 <book> elements. ...

How IE's and Firefox's XML DOM parsers deal with whitespace text nodes #2
Can someone please explain this section of this tutorial me? http://www.w3schools.com/dom/dom_mozilla_vs_ie.asp The relevant text I do not understand is: "Internet Explorer, when using node.childNodes[], will NOT contain these white-space nodes. In Mozilla, those nodes will be in the array." and "Internet Explorer will skip the white-space text nodes that are generated between nodes (e.g. new line characters), while Mozilla will not. So, in the example above, Mozilla browsers will alert 9 child nodes, while Internet Explorer will alert 4." I checked the said file: http://www.w3schools.com/dom/books.xml In both, Firefox 2.0 as well as IE 6.0, it had only 4 <book> elements. Water Cooler v2 wrote: > The relevant text I do not understand is: > > "Internet Explorer, when using node.childNodes[], will NOT contain > these white-space nodes. In Mozilla, those nodes will be in the > array." > > and > > "Internet Explorer will skip the white-space text nodes that are > generated between nodes (e.g. new line characters), while Mozilla will > not. So, in the example above, Mozilla browsers will alert 9 child > nodes, while Internet Explorer will alert 4." > > I checked the said file: http://www.w3schools.com/dom/books.xml > > In both, Firefox 2.0 as well as IE 6.0, it had only 4 <book> elements. The DOM object model knows different kind of nodes, it knows element nodes but...

Xml exported text
I have a file that was exported as an XML file using UFT-8 encoding. Is there a module that will allow me to convert the text so that it is readable on a Unix system. The text needs to be imported into a legacy system that does not understand UTF-8 so I end up losing some characters (',",`,\t etc). Any help would be greatly appreicated. ...

Web resources about - extracting text from an XML node - comp.text.xml

Local Measure addresses the importance of extracting value from Big Data
There are many opportunities surrounding the Big Data space and if businesses milk the value from all the data they’ve got, it can change the ...

Dentist deregistered after extracting teeth and performing root canal work without patients’ consent
A DOWN-in-the-mouth dentist who extracted wisdom teeth and performed root canal work on patients without their consent has been deregistered ...

Extracting the digital
Alexa Moses tries to make sense of the Resfest digital film festival. - Sydney Morning Herald Online

Shy bidders' tactics make extracting bids almost as painful as dental work
Shy bidders' tactics make extracting bids almost as painful as dental work

Brookfield 'ruthless' in extracting infrastructure profits, says CBH
The nation's biggest grain exporter CBH Group has thrown its weight behind concerns by farmers over Brookfield's $8.9 billion proposed takeover ...

Companies extracting B.C. groundwater for free
Several groups are calling on the province to tighten groundwater laws as B.C. is the only jurisdiction in Canada that does not charge major ...

Extracting info: Why’s it so hard to get the goods on oil spills?
It can be tough to get a good sense of how safe Alberta’s oil industry is when you can’t access the information you need.

Krugman on extracting a price for intellectual dishonesty
Just a small point, but with it I want to make a larger one. ■ The small point is about Paul Krugman and his slow path to calling out his professional ...

When Oil Isn’t Worth Extracting
... the point at which energy resources become too costly to take out of the earth: We’ll never run out of any fossil fuel, in the sense of extracting ...

Revenge is ours: extracting energy from a cockroach
... inside it to use it as a mini-electricity generator. Now, I hate cockroaches as much as anyone, and there is a certain satisfaction in extracting ...

Resources last updated: 3/13/2016 9:51:09 PM