Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everyone,

I have a problem in copying a text from one richtextbox1 to another richtextbox2 based on the expression which we give in the regular expresssion.


XML
<b>
    <FamilyId>587200256</FamilyId>
    <URN>05080100112010341</URN>
    <VernacularName>-</VernacularName>
    <FatherHusbandName>Sham Ram</FatherHusbandName>
    <HeadMemberId>1</HeadMemberId>
    <DoorHouseNo>-</DoorHouseNo>
    <VillageCode>01049400</VillageCode>
    <PanchayatTownCode>50872003</PanchayatTownCode>
    <BlockCode>0072</BlockCode>
    <DistrictCode>08</DistrictCode>
    <StateCode>05</StateCode>
    <BPLCitizen>01</BPLCitizen>
    <IsEnrolled>true</IsEnrolled>
    <EnrolledDateTime>2012-07-30T18:18:45.7+05:30</EnrolledDateTime>
    <IsCardPersonalized>false</IsCardPersonalized>
    <IsCardIssued>false</IsCardIssued>
    <IsExported>true</IsExported>
    <ExportDateTime>2012-08-14T17:46:43.957+05:30</ExportDateTime>
    <DigitalSignatureVerified>true</DigitalSignatureVerified>
    <SignedPersonalizationData>&#x0;&#x0;&#x0;&#x0;</SignedPersonalizationData>
    <RSBYType>99</RSBYType>
    <IsCardIssuedLastYear>false</IsCardIssuedLastYear>
    <CategoryCode>01</CategoryCode>
    <Minority>2</Minority>
    <PremiumStatus xml:space="preserve"> </PremiumStatus>
    <EKey>4D-18-D5-37-F8-61-83-10-C3-91-63-C3-2C-E0-D9-CD</EKey>
    <FontType>U</FontType>
    <FontName>Unicode</FontName>
    <OldURN>00083681051049404</OldURN>
    <EncryptedText>16BA9C9601BE8A750CBBF66DF89A4BF228AD69B3B11236482F282E65A72377489EE12DEC09FA6075</EncryptedText>
    <ExportedBatchNo>4295</ExportedBatchNo>
    <OperatorId>100002</OperatorId>
    <SystemName>SIRISHA</SystemName>
    <EnrollmentStationId>00:23:54:FF:B6:DF</EnrollmentStationId>
    <UploadStatus>N</UploadStatus>
    <UploadDateTime>2012-07-30T18:18:45.7+05:30</UploadDateTime>
  </b>
Posted
Updated 2-Sep-12 20:00pm
v2
Comments
Devang Vaja 3-Sep-12 1:50am    
can you elaborate?????
Rockstar_ 3-Sep-12 1:54am    
I have a text in richtextbox, i want to copy text from the richtextbox between the two indexes and that copied text paste in other richtextbox. We dont know the particular index, we know only the text.
Kenneth Haugland 3-Sep-12 1:56am    
So your problem is getting the Caret position from the search results?
Rockstar_ 3-Sep-12 1:58am    
i have a tags like and , and i want to copy text between these tags.
AmitGajjar 3-Sep-12 2:08am    
Why you have posted this xml file? does it related to your problem ?

1 solution

If it's about extracting some text from XML and process it, see http://support.microsoft.com/kb/317662[^].

If you insist on using Regex to extract all text from the XML, see Remove all the HTML tags and display a plain text only inside (in case XML is not well formed)[^].

If you want to extract a specific portion of the XML data, you may try something like
C#
string xml = ...;
var match = Regex.Match(xml, @"<MyElement.*?>([\s\S]*?)</MyElement>");
string result = match.Success ? match.Group[1].Value : null;


You still face the problem that the text may contain xml entities. These would need to be replaced by the respective plain characters. This needs a bit of creativity. I would then discard the regex solution and use xml dom approach, e.g. by employing http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.loadxml.aspx[^] and accesing the inner text of a respective node.

Cheers
Andi
 
Share this answer
 
v2
Comments
Kenneth Haugland 3-Sep-12 16:09pm    
AS good a guess as any, 5'ed.
Andreas Gieriet 3-Sep-12 16:52pm    
Thanks for your 5, Kenneth!
Was an attmpt to solve the riddle ;-)
Kenneth Haugland 3-Sep-12 18:51pm    
Im still struggeling with it :-D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900