473,382 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Parsing custom tag in XML node ??

Hi All,

I have a piece of HTML stored in a CDATA xml node, and would like a
way to provide the content-editor who's enters the text a friendly way
to specify a search query, something like:

<ROOT>
<bodytext><![[CDATA[this is a example of the <b>HTML</b> text.<br>
Click <searchbyname arg="john">Here</searchbyname> to
get John's search results, or click <searchbyID
arg="111">Here</searchbyID> to search by ID.
</bodytext>
</ROOT>

I figured that <searchbyname> and <searchbyID> are child elements of
<bodytext>, but I'm not sure how to do my substitutions, and then
reassemble back into a HTML string that I can output.

any ideas? or is there another way I could do this? I thought about
brute-force string.indexof() and string.replace(), but there's
probably a beter way.

Thanks
Lightman
Nov 12 '05 #1
2 2333
lightman wrote:
I have a piece of HTML stored in a CDATA xml node, and would like a
way to provide the content-editor who's enters the text a friendly way
to specify a search query, something like:

<ROOT>
<bodytext><![[CDATA[this is a example of the <b>HTML</b> text.<br>
Click <searchbyname arg="john">Here</searchbyname> to
get John's search results, or click <searchbyID
arg="111">Here</searchbyID> to search by ID.
</bodytext>
</ROOT>
This is malformed XML. CDATA start tag is misspelled and end tag is
absent. Here is well-formed version:

<ROOT>
<bodytext><![CDATA[this is a example of the <b>HTML</b> text.<br>
Click <searchbyname arg="john">Here</searchbyname> to
get John's search results, or click <searchbyID
arg="111">Here</searchbyID> to search by ID.]]>
</bodytext>
</ROOT>
I figured that <searchbyname> and <searchbyID> are child elements of
<bodytext>, but I'm not sure how to do my substitutions, and then
reassemble back into a HTML string that I can output.


No elements in CDATA. CDATA means the content is just plain text. So to
process it use common text processing means (substring functions, regexp
etc), forget about XML facilities. Otherwise avoid CDATA.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
lightman wrote:
I have a piece of HTML stored in a CDATA xml node, and would like a
way to provide the content-editor who's enters the text a friendly way
to specify a search query, something like:

<ROOT>
<bodytext><![[CDATA[this is a example of the <b>HTML</b> text.<br>
Click <searchbyname arg="john">Here</searchbyname> to
get John's search results, or click <searchbyID
arg="111">Here</searchbyID> to search by ID.
</bodytext>
</ROOT>
This is malformed XML. CDATA start tag is misspelled and end tag is
absent. Here is well-formed version:

<ROOT>
<bodytext><![CDATA[this is a example of the <b>HTML</b> text.<br>
Click <searchbyname arg="john">Here</searchbyname> to
get John's search results, or click <searchbyID
arg="111">Here</searchbyID> to search by ID.]]>
</bodytext>
</ROOT>
I figured that <searchbyname> and <searchbyID> are child elements of
<bodytext>, but I'm not sure how to do my substitutions, and then
reassemble back into a HTML string that I can output.


No elements in CDATA. CDATA means the content is just plain text. So to
process it use common text processing means (substring functions, regexp
etc), forget about XML facilities. Otherwise avoid CDATA.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #3

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

Similar topics

0
by: burn_hall | last post by:
Hi, I have a problem and can't figure it out and need your help, please look at the following code and the output also a xml file snippet is down there too. Looking at the output I don't know why...
19
by: Alex Mizrahi | last post by:
Hello, All! i have 3mb long XML document with about 150000 lines (i think it has about 200000 elements there) which i want to parse to DOM to work with. first i thought there will be no...
0
by: Yang Xiao | last post by:
Hi all, I'm having some problems with parsing XML with DOMParser. What I want is to filter out particular elements in the XML, the sample XML looks like this. Thanks in advance. Yang ...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
1
by: Hazzard | last post by:
I am trying to create a custom section and section handler in my config file. The custom section should be something like; <appSecurity> <method name = "Protect the Ice Cream"> <allow group =...
1
by: Hazzard | last post by:
I am trying to create a custom section and section handler in my config file. The custom section should be something like; <appSecurity> <method name = "Protect the Ice Cream"> <allow group =...
0
by: XML newbie: Urgent pls help! | last post by:
When I try to parse: I get the following error message: Unable to cast COM object of type 'Microsoft.SqlServer.MSXML6.DOMDocumentClass' to interface type 'MSXML2.ServerXMLHTTP40'. This operation...
0
by: XML newbie: Urgent pls help! | last post by:
I am using Vb.net. I am new to XML.I appreciate your help in advance. Please reply soon. When I try to parse: I get the following error message: Unable to cast COM object of type...
5
by: WTH | last post by:
In C++ I had, long ago, written my own XML parsing class as I never found even a half decent node based hierarchical solution that was simple, now that I'm starting to develop tools in C# (as a...
2
by: nicky123 | last post by:
Hi everyone, This is a brief description that I have provided for parsing & displaying an XML document using DOM API. Please feel free to post your own comments & views regarding...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.